hongbin ma created KYLIN-2599:
---------------------------------

             Summary: 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)

Reply via email to