[ https://issues.apache.org/jira/browse/KYLIN-2599?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16004116#comment-16004116 ]
hongbin ma edited comment on KYLIN-2599 at 5/10/17 5:49 AM: ------------------------------------------------------------ similar exception is thrown when I test query like: {code:sql} select lstg_format_name from test_kylin_fact order by case when 1=1 then cal_dt ELSE seller_id end {code} To fix the issue more completely, we'll: 1. check if rootProj has any field starting with "_KY_", if none is found, then current logical plan does not require hacking, org.apache.calcite.sql2rel.SqlToRelConverter#hackSelectStar should abort by returning root. 2. the field list of rootProj may be longer than that of root (in case of kylin-it/src/test/resources/query/sql_verifyCount/query10.sql), so when constructing validatedRowType we'll skip the longer tail on rootProj 3. sort rel's RelCollation (if any) may become stale after removing the "_KY_" fields, need to fix its fieldIndex was (Author: mahongbin): similar exception is thrown when I test query like: {code:sql} select lstg_format_name from test_kylin_fact order by case when 1=1 then cal_dt ELSE seller_id end {code} To fix the issue more completely, we'll: 1. check if rootProj has any field starting with "_KY_", if none is found, then current logical plan does not require hacking, org.apache.calcite.sql2rel.SqlToRelConverter#hackSelectStar should abort by returning root. 2. the field list of rootProj may be longer than that of root (in case of kylin-it/src/test/resources/query/sql_verifyCount/query10.sql), so when constructing validatedRowType we'll skip the longer tail on rootProj 3. sort rel's RelCollation (if any) may become stale after removing the "_KY_" fields, need to fix its fieldIndex > select * in subquery fail due to bug in hackSelectStar > ------------------------------------------------------- > > Key: KYLIN-2599 > URL: https://issues.apache.org/jira/browse/KYLIN-2599 > Project: Kylin > Issue Type: Improvement > Reporter: hongbin ma > > {code:sql} > select fact.lstg_format_name from > > (select * from test_kylin_fact where cal_dt > date'2010-01-01' ) as fact > > group by fact.lstg_format_name > > order by CASE WHEN fact.lstg_format_name IS NULL THEN 'sdf' ELSE > fact.lstg_format_name END > > {code} > will generate logical plan like: > {code} > LogicalSort(sort0=[$1], dir0=[ASC]) > LogicalProject(LSTG_FORMAT_NAME=[$0], EXPR$1=[CASE(IS NULL($0), 'sdf', $0)]) > LogicalAggregate(group=[{0}]) > LogicalProject(LSTG_FORMAT_NAME=[$3]) > LogicalProject(TRANS_ID=[$0], ORDER_ID=[$1], CAL_DT=[$2], > LSTG_FORMAT_NAME=[$3], LEAF_CATEG_ID=[$4], LSTG_SITE_ID=[$5], > SLR_SEGMENT_CD=[$6], SELLER_ID=[$7], PRICE=[$8], ITEM_COUNT=[$9], > TEST_COUNT_DISTINCT_BITMAP=[$10], DEAL_AMOUNT=[$11], DEAL_YEAR=[$12], > _KY_COUNT__=[$13], _KY_MIN_TEST_KYLIN_FACT_PRICE_=[$14], > _KY_MAX_TEST_KYLIN_FACT_PRICE_=[$15], > _KY_COUNT_DISTINCT_TEST_KYLIN_FACT_SELLER_ID_=[$16], > _KY_COUNT_DISTINCT_TEST_KYLIN_FACT_LSTG_FORMAT_NAME_TEST_KYLIN_FACT_SELLER_ID_=[$17], > _KY_COUNT_DISTINCT_TEST_KYLIN_FACT_TEST_COUNT_DISTINCT_BITMAP_=[$18], > _KY_PERCENTILE_TEST_KYLIN_FACT_PRICE_=[$19]) > LogicalFilter(condition=[>($2, 2010-01-01)]) > OLAPTableScan(table=[[DEFAULT, TEST_KYLIN_FACT]], fields=[[0, 1, > 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]]) > {code} > org.apache.calcite.sql2rel.SqlToRelConverter#hackSelectStar will by mistake > treat it like a normal case and lead to throwing exception -- This message was sent by Atlassian JIRA (v6.3.15#6346)