[
https://issues.apache.org/jira/browse/CALCITE-4362?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17431445#comment-17431445
]
Stamatis Zampetakis commented on CALCITE-4362:
----------------------------------------------
I completely agree with [~julianhyde].
I might have done something like that in a previous project I was working on.
Vaguely I remember I drew inspiration from the way rolled up columns are
handled in
[SqlValidatorImpl.expandStar|https://github.com/apache/calcite/blob/bf962b86d9c27ca429ae71bf75a2acdca06eee91/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java#L635].
The trick is to find the table to which the column belongs and the latter
should implement an appropriate interface (such as
[Table.isRolledUp|https://github.com/apache/calcite/blob/bf962b86d9c27ca429ae71bf75a2acdca06eee91/core/src/main/java/org/apache/calcite/schema/Table.java#L71]
) to be able to tell if a column is a system column or not.
For that use-case, I think I ended up sub-classing {{SqlValidatorImpl}} and
overloading
[SqlValidatorImpl.addToSelectList|https://github.com/apache/calcite/blob/bf962b86d9c27ca429ae71bf75a2acdca06eee91/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java#L2067]
as an attempt to not modify Calcite. I guess if want to make this part of the
core it will be easier.
> Unable to parse queries that use BigQuery pseudo columns
> _PARTITIONDATE/_PARTITIONTIME
> --------------------------------------------------------------------------------------
>
> Key: CALCITE-4362
> URL: https://issues.apache.org/jira/browse/CALCITE-4362
> Project: Calcite
> Issue Type: Bug
> Components: babel
> Reporter: Justin Swett
> Assignee: Julian Hyde
> Priority: Major
>
> BigQuery supports partitioned tables using pseudo columns "_PARTITIONDATE"
> e.g. The following table has two columns you can select from but also
> partitions the data by creation date
> {code:java}
> CREATE or REPLACE TABLE #{table} (
> transaction_id STRING,
> order_date DATE )
> PARTITION BY _PARTITIONDATE
> {code}
>
> The following queries cannot be validated
> {code:java}
> select * from #{table} where _PARTITIONDATE = '2020-11-03' ;
> -- OR
> select * from #{table} where _PARTITIONTIME = '2020-11-03' ;{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)