You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Zhen Chen (Jira)" <ji...@apache.org> on 2025/12/14 02:34:00 UTC

[jira] [Commented] (CALCITE-7328) Support SCALAR_QUERY in RelMdExpressionLineage

    [ https://issues.apache.org/jira/browse/CALCITE-7328?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18044919#comment-18044919 ] 

Zhen Chen commented on CALCITE-7328:
------------------------------------

I suggest keeping the Agg format unchanged for now. Currently, SQL2 still outputs a comparison expression. If it didn't return the comparison expression, something like `[[CATALOG, SALES, PRODUCTS_TEMPORAL].#0.$0, [CATALOG, SALES, PRODUCTS_TEMPORAL].#0.$0]`, I think it could be simplified. However, I'm not sure if it should describe the overall relationship X > Y. If it were something like `select (select productid from products_temporal where productid = 1) as productid`, I think it would be appropriate to return `[[CATALOG, SALES, PRODUCTS_TEMPORAL].#0.$0]`. Do you have any better suggestions?

> Support SCALAR_QUERY in RelMdExpressionLineage
> ----------------------------------------------
>
>                 Key: CALCITE-7328
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7328
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: xiong duan
>            Priority: Major
>
> The SQL1:
> {code:java}
> select 
> (select max(productid) from products_temporal) as maxValue, 
> (select min(productid) from products_temporal) as minValue {code}
> The ExpressionLineage of this SQL is NULL.
> The SQL2:
> {code:java}
> select 
> productid > (select max(productid) from products_temporal) as productidValues 
> from products_temporal {code}
> The ExpressionLineage of this SQL is :
> {code:java}
> [>([CATALOG, SALES, PRODUCTS_TEMPORAL].#0.$0, $SCALAR_QUERY({\nLogicalAggregate(group=[{}], EXPR$0=[MAX($0)])\r\n  LogicalProject(PRODUCTID=[$0])\r\n    LogicalTableScan(table=[[CATALOG, SALES, PRODUCTS_TEMPORAL]])\r\n}))]{code}
> There are two issues here:
>  # SQL1 should return result.
>  # Whether or not to unwrap the SCALAR_QUERY. For example in SQL2 like this:
> {code:java}
> [>([CATALOG, SALES, PRODUCTS_TEMPORAL].#0.$0,MAX[CATALOG, SALES, PRODUCTS_TEMPORAL].#0.$0{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)