Fix Orca CTAS for tables created with legacy vs non-legacy hashops (#10833)
For CTAS creating tables with non-legacy hashop distribution from tables with legacy hashops, CTAS with Orca would distribute the data according to the value of gp_use_legacy_hashops; however, it would set the table's distribution policy hashop to the value of the original table. This caused queries to give incorrect results as the distribution policy mismatched the data distribution. The data was being distributed correctly as we used the correct opfamily internally in Orca when determining the distribution spec. However, when populating the distribution policy value in the table in CTranslatorDXLToPlStmt.cpp, we were trying to derive the opclass from the opfamily. This doesn't work, and instead we need to pass the opclass from the query through Orca and to the plan statement. Hence we use the opfamily internally within Orca, and simply pass through the opclass to populate the gp_distribution_policy value correctly. Additionally, CTAS minidumps have been failing for quite a while, and subsequent changes made this a bit difficult to untangle. Since we only have ~10 mdp files, I simply regenerated most of these files and made the opfamily/opclasses arrays required as part of CMDRelationCTAS, LogicalCTAS, and PhysicalCTAS. Also, remove the `GPOS_ASSERT(NULL == mdhtacc.Find());` assert in CMDAccessor.cpp. We've been hitting this with newly created mdps since at least a couple of years, but haven't added new CTAS mdps since then. Removing the assert doesn't seem to cause any problems and it's only relevant for mdps.
Showing
此差异已折叠。
想要评论请 注册 或 登录