Honestly, I don't know the details. I just know that on our application we
use "withIdentifierExpansion(true)", to avoid potential issues (I guess
like the one you had).
Several internal Calcite classes do the same, maybe someone with more
experience on the SqlValidator could give more info.


Regarding the SUBSTR issue, I was expecting that changing the
CalciteConnectionConfig as:
  CalciteConnectionConfig.DEFAULT
    .set(CalciteConnectionProperty.CASE_SENSITIVE, "false")
    .set(CalciteConnectionProperty.FUN, "oracle")
would do the trick; but it seems it does not.

Instead, what I think would work in your test would be leaving the
CalciteConnectionConfig as you have it, and enlarge the
SqlStdOperatorTable: instead of just
  SqlStdOperatorTable.instance()
use
  SqlOperatorTables.chain(SqlStdOperatorTable.instance(),
SqlLibraryOperatorTableFactory.INSTANCE.getOperatorTable(SqlLibrary.ORACLE))
(or whatever SqlLibrary suits your needs). Could you verify it?



On Wed, Feb 24, 2021 at 5:30 PM Priyendra Deshwal <[email protected]>
wrote:

> On Wed, Feb 24, 2021 at 8:26 AM Ruben Q L <[email protected]> wrote:
>
> > Could you please verify if changing this line:
> >   SqlValidator.Config.DEFAULT
> > and using this instead:
> >    SqlValidator.Config.DEFAULT.withIdentifierExpansion(true)
> > solves your issue with the partition query?
> >
>
> Nice. That did solve the issue for me. Can you provide me some explanation
> for what may be happening here?
>
> On Wed, Feb 24, 2021 at 3:26 PM Priyendra Deshwal <[email protected]>
> > wrote:
> >
> > > I am unsure if the patch attachment came through in the previous
> email. I
> > > was unable to see it on the web archive. Here's the patch directly in
> the
> > > email itself.
> > >
> > > commit a8d539ecd209812d22d4a7e2a82e5ed56e4f02a3
> > > Author: deshwal <[email protected]>
> > >
> > >     Test case to demonstrate the partition over problem.
> > >
> > > diff --git
> > >
> >
> a/plus/src/test/java/org/apache/calcite/adapter/tpcds/TpcdsDeshwalTest.java
> > >
> >
> b/plus/src/test/java/org/apache/calcite/adapter/tpcds/TpcdsDeshwalTest.java
> > > new file mode 100644
> > > index 000000000..256032e2c
> > > --- /dev/null
> > > +++
> > >
> >
> b/plus/src/test/java/org/apache/calcite/adapter/tpcds/TpcdsDeshwalTest.java
> > > @@ -0,0 +1,692 @@
> > > +package org.apache.calcite.adapter.tpcds;
> > > +
> > > +import java.io.File;
> > > +import java.io.IOException;
> > > +import java.nio.file.Files;
> > > +import java.nio.file.Path;
> > > +import java.nio.file.Paths;
> > > +import java.util.Arrays;
> > > +import java.util.Collections;
> > > +import java.util.List;
> > > +import java.util.Properties;
> > > +import java.util.Set;
> > > +import org.apache.calcite.avatica.util.Quoting;
> > > +import org.apache.calcite.config.CalciteConnectionConfig;
> > > +import org.apache.calcite.config.CalciteConnectionProperty;
> > > +import org.apache.calcite.jdbc.CalciteSchema;
> > > +import org.apache.calcite.jdbc.JavaTypeFactoryImpl;
> > > +import org.apache.calcite.plan.ConventionTraitDef;
> > > +import org.apache.calcite.plan.RelOptCluster;
> > > +import org.apache.calcite.plan.RelOptTable;
> > > +import org.apache.calcite.plan.RelOptUtil;
> > > +import org.apache.calcite.plan.volcano.VolcanoPlanner;
> > > +import org.apache.calcite.prepare.CalciteCatalogReader;
> > > +import org.apache.calcite.rel.RelNode;
> > > +import org.apache.calcite.rel.RelRoot;
> > > +import org.apache.calcite.rel.type.RelDataType;
> > > +import org.apache.calcite.rel.type.RelDataTypeFactory;
> > > +import org.apache.calcite.rex.RexBuilder;
> > > +import org.apache.calcite.schema.impl.AbstractTable;
> > > +import org.apache.calcite.sql.SqlExplainFormat;
> > > +import org.apache.calcite.sql.SqlExplainLevel;
> > > +import org.apache.calcite.sql.SqlNode;
> > > +import org.apache.calcite.sql.fun.SqlStdOperatorTable;
> > > +import org.apache.calcite.sql.parser.SqlParseException;
> > > +import org.apache.calcite.sql.parser.SqlParser;
> > > +import org.apache.calcite.sql.type.SqlTypeName;
> > > +import org.apache.calcite.sql.validate.SqlValidator;
> > > +import org.apache.calcite.sql.validate.SqlValidatorUtil;
> > > +import org.apache.calcite.sql2rel.SqlToRelConverter;
> > > +import org.apache.calcite.sql2rel.StandardConvertletTable;
> > > +
> > > +import org.junit.jupiter.api.Test;
> > > +
> > > +// This program serves as a template for how we can use Calcite for
> Flux
> > > +// query planning.
> > > +public class TpcdsDeshwalTest {
> > > +  private static class Column {
> > > +    Column(String name, SqlTypeName dataType) {
> > > +      this.name = name;
> > > +      this.dataType = dataType;
> > > +    }
> > > +    private String name;
> > > +    private SqlTypeName dataType;
> > > +  }
> > > +  private static class Table extends AbstractTable {
> > > +    private final RelDataType rowType_;
> > > +    Table(RelDataTypeFactory typeFactory, Column... columns) {
> > > +      RelDataTypeFactory.Builder builder = new
> > > RelDataTypeFactory.Builder(typeFactory);
> > > +      for (Column column : columns) builder.add(column.name,
> > > column.dataType);
> > > +      rowType_ = builder.build();
> > > +    }
> > > +    @Override
> > > +    public RelDataType getRowType(final RelDataTypeFactory
> typeFactory)
> > {
> > > +      return rowType_;
> > > +    }
> > > +  }
> > > +
> > > +  // This function returns a tpcds schema. We intentionally do not use
> > the
> > > +  // implementation at org.apache.calcite.adapter.tpcds.TpcdsSchema
> > which
> > > +  // is already provided by Calcite to illustrate how we may setup the
> > > +  // schema for NetSpring tables.
> > > +  // TODO: Should we convert this into a Schema instead of
> > CalciteSchema?
> > > +  private static CalciteSchema newTpcdsSchema(
> > > +      RelDataTypeFactory typeFactory) {
> > > +    CalciteSchema schema = CalciteSchema.createRootSchema(true);
> > > +    schema.add(
> > > +        "catalog_sales",
> > > +        new Table(
> > > +            typeFactory,
> > > +            new Column("cs_sold_date_sk", SqlTypeName.BIGINT),
> > > +            new Column("cs_sold_time_sk", SqlTypeName.BIGINT),
> > > +            new Column("cs_ship_date_sk", SqlTypeName.BIGINT),
> > > +            new Column("cs_bill_customer_sk", SqlTypeName.BIGINT),
> > > +            new Column("cs_bill_cdemo_sk", SqlTypeName.BIGINT),
> > > +            new Column("cs_bill_hdemo_sk", SqlTypeName.BIGINT),
> > > +            new Column("cs_bill_addr_sk", SqlTypeName.BIGINT),
> > > +            new Column("cs_ship_customer_sk", SqlTypeName.BIGINT),
> > > +            new Column("cs_ship_cdemo_sk", SqlTypeName.BIGINT),
> > > +            new Column("cs_ship_hdemo_sk", SqlTypeName.BIGINT),
> > > +            new Column("cs_ship_addr_sk", SqlTypeName.BIGINT),
> > > +            new Column("cs_call_center_sk", SqlTypeName.BIGINT),
> > > +            new Column("cs_catalog_page_sk", SqlTypeName.BIGINT),
> > > +            new Column("cs_ship_mode_sk", SqlTypeName.BIGINT),
> > > +            new Column("cs_warehouse_sk", SqlTypeName.BIGINT),
> > > +            new Column("cs_item_sk", SqlTypeName.BIGINT),
> > > +            new Column("cs_promo_sk", SqlTypeName.BIGINT),
> > > +            new Column("cs_order_number", SqlTypeName.BIGINT),
> > > +            new Column("cs_quantity", SqlTypeName.BIGINT),
> > > +            new Column("cs_wholesale_cost", SqlTypeName.DOUBLE),
> > > +            new Column("cs_list_price", SqlTypeName.DOUBLE),
> > > +            new Column("cs_sales_price", SqlTypeName.DOUBLE),
> > > +            new Column("cs_ext_discount_amt", SqlTypeName.DOUBLE),
> > > +            new Column("cs_ext_sales_price", SqlTypeName.DOUBLE),
> > > +            new Column("cs_ext_wholesale_cost", SqlTypeName.DOUBLE),
> > > +            new Column("cs_ext_list_price", SqlTypeName.DOUBLE),
> > > +            new Column("cs_ext_tax", SqlTypeName.DOUBLE),
> > > +            new Column("cs_coupon_amt", SqlTypeName.DOUBLE),
> > > +            new Column("cs_ext_ship_cost", SqlTypeName.DOUBLE),
> > > +            new Column("cs_net_paid", SqlTypeName.DOUBLE),
> > > +            new Column("cs_net_paid_inc_tax", SqlTypeName.DOUBLE),
> > > +            new Column("cs_net_paid_inc_ship", SqlTypeName.DOUBLE),
> > > +            new Column("cs_net_paid_inc_ship_tax",
> SqlTypeName.DOUBLE),
> > > +            new Column("cs_net_profit", SqlTypeName.DOUBLE)));
> > > +    schema.add(
> > > +        "catalog_returns",
> > > +        new Table(
> > > +            typeFactory,
> > > +            new Column("cr_returned_date_sk", SqlTypeName.BIGINT),
> > > +            new Column("cr_returned_time_sk", SqlTypeName.BIGINT),
> > > +            new Column("cr_item_sk", SqlTypeName.BIGINT),
> > > +            new Column("cr_refunded_customer_sk", SqlTypeName.BIGINT),
> > > +            new Column("cr_refunded_cdemo_sk", SqlTypeName.BIGINT),
> > > +            new Column("cr_refunded_hdemo_sk", SqlTypeName.BIGINT),
> > > +            new Column("cr_refunded_addr_sk", SqlTypeName.BIGINT),
> > > +            new Column("cr_returning_customer_sk",
> SqlTypeName.BIGINT),
> > > +            new Column("cr_returning_cdemo_sk", SqlTypeName.BIGINT),
> > > +            new Column("cr_returning_hdemo_sk", SqlTypeName.BIGINT),
> > > +            new Column("cr_returning_addr_sk", SqlTypeName.BIGINT),
> > > +            new Column("cr_call_center_sk", SqlTypeName.BIGINT),
> > > +            new Column("cr_catalog_page_sk", SqlTypeName.BIGINT),
> > > +            new Column("cr_ship_mode_sk", SqlTypeName.BIGINT),
> > > +            new Column("cr_warehouse_sk", SqlTypeName.BIGINT),
> > > +            new Column("cr_reason_sk", SqlTypeName.BIGINT),
> > > +            new Column("cr_order_number", SqlTypeName.BIGINT),
> > > +            new Column("cr_return_quantity", SqlTypeName.BIGINT),
> > > +            new Column("cr_return_amount", SqlTypeName.DOUBLE),
> > > +            new Column("cr_return_tax", SqlTypeName.DOUBLE),
> > > +            new Column("cr_return_amt_inc_tax", SqlTypeName.DOUBLE),
> > > +            new Column("cr_fee", SqlTypeName.DOUBLE),
> > > +            new Column("cr_return_ship_cost", SqlTypeName.DOUBLE),
> > > +            new Column("cr_refunded_cash", SqlTypeName.DOUBLE),
> > > +            new Column("cr_reversed_charge", SqlTypeName.DOUBLE),
> > > +            new Column("cr_store_credit", SqlTypeName.DOUBLE),
> > > +            new Column("cr_net_loss", SqlTypeName.DOUBLE)));
> > > +    schema.add(
> > > +        "inventory",
> > > +        new Table(
> > > +            typeFactory,
> > > +            new Column("inv_date_sk", SqlTypeName.BIGINT),
> > > +            new Column("inv_item_sk", SqlTypeName.BIGINT),
> > > +            new Column("inv_warehouse_sk", SqlTypeName.BIGINT),
> > > +            new Column("inv_quantity_on_hand", SqlTypeName.BIGINT)));
> > > +    schema.add(
> > > +        "store_sales",
> > > +        new Table(
> > > +            typeFactory,
> > > +            new Column("ss_sold_date_sk", SqlTypeName.BIGINT),
> > > +            new Column("ss_sold_time_sk", SqlTypeName.BIGINT),
> > > +            new Column("ss_item_sk", SqlTypeName.BIGINT),
> > > +            new Column("ss_customer_sk", SqlTypeName.BIGINT),
> > > +            new Column("ss_cdemo_sk", SqlTypeName.BIGINT),
> > > +            new Column("ss_hdemo_sk", SqlTypeName.BIGINT),
> > > +            new Column("ss_addr_sk", SqlTypeName.BIGINT),
> > > +            new Column("ss_store_sk", SqlTypeName.BIGINT),
> > > +            new Column("ss_promo_sk", SqlTypeName.BIGINT),
> > > +            new Column("ss_ticket_number", SqlTypeName.BIGINT),
> > > +            new Column("ss_quantity", SqlTypeName.BIGINT),
> > > +            new Column("ss_wholesale_cost", SqlTypeName.DOUBLE),
> > > +            new Column("ss_list_price", SqlTypeName.DOUBLE),
> > > +            new Column("ss_sales_price", SqlTypeName.DOUBLE),
> > > +            new Column("ss_ext_discount_amt", SqlTypeName.DOUBLE),
> > > +            new Column("ss_ext_sales_price", SqlTypeName.DOUBLE),
> > > +            new Column("ss_ext_wholesale_cost", SqlTypeName.DOUBLE),
> > > +            new Column("ss_ext_list_price", SqlTypeName.DOUBLE),
> > > +            new Column("ss_ext_tax", SqlTypeName.DOUBLE),
> > > +            new Column("ss_coupon_amt", SqlTypeName.DOUBLE),
> > > +            new Column("ss_net_paid", SqlTypeName.DOUBLE),
> > > +            new Column("ss_net_paid_inc_tax", SqlTypeName.DOUBLE),
> > > +            new Column("ss_net_profit", SqlTypeName.DOUBLE)));
> > > +    schema.add(
> > > +        "store_returns",
> > > +        new Table(
> > > +            typeFactory,
> > > +            new Column("sr_returned_date_sk", SqlTypeName.BIGINT),
> > > +            new Column("sr_return_time_sk", SqlTypeName.BIGINT),
> > > +            new Column("sr_item_sk", SqlTypeName.BIGINT),
> > > +            new Column("sr_customer_sk", SqlTypeName.BIGINT),
> > > +            new Column("sr_cdemo_sk", SqlTypeName.BIGINT),
> > > +            new Column("sr_hdemo_sk", SqlTypeName.BIGINT),
> > > +            new Column("sr_addr_sk", SqlTypeName.BIGINT),
> > > +            new Column("sr_store_sk", SqlTypeName.BIGINT),
> > > +            new Column("sr_reason_sk", SqlTypeName.BIGINT),
> > > +            new Column("sr_ticket_number", SqlTypeName.BIGINT),
> > > +            new Column("sr_return_quantity", SqlTypeName.BIGINT),
> > > +            new Column("sr_return_amt", SqlTypeName.DOUBLE),
> > > +            new Column("sr_return_tax", SqlTypeName.DOUBLE),
> > > +            new Column("sr_return_amt_inc_tax", SqlTypeName.DOUBLE),
> > > +            new Column("sr_fee", SqlTypeName.DOUBLE),
> > > +            new Column("sr_return_ship_cost", SqlTypeName.DOUBLE),
> > > +            new Column("sr_refunded_cash", SqlTypeName.DOUBLE),
> > > +            new Column("sr_reversed_charge", SqlTypeName.DOUBLE),
> > > +            new Column("sr_store_credit", SqlTypeName.DOUBLE),
> > > +            new Column("sr_net_loss", SqlTypeName.DOUBLE)));
> > > +    schema.add(
> > > +        "web_sales",
> > > +        new Table(
> > > +            typeFactory,
> > > +            new Column("ws_sold_date_sk", SqlTypeName.BIGINT),
> > > +            new Column("ws_sold_time_sk", SqlTypeName.BIGINT),
> > > +            new Column("ws_ship_date_sk", SqlTypeName.BIGINT),
> > > +            new Column("ws_item_sk", SqlTypeName.BIGINT),
> > > +            new Column("ws_bill_customer_sk", SqlTypeName.BIGINT),
> > > +            new Column("ws_bill_cdemo_sk", SqlTypeName.BIGINT),
> > > +            new Column("ws_bill_hdemo_sk", SqlTypeName.BIGINT),
> > > +            new Column("ws_bill_addr_sk", SqlTypeName.BIGINT),
> > > +            new Column("ws_ship_customer_sk", SqlTypeName.BIGINT),
> > > +            new Column("ws_ship_cdemo_sk", SqlTypeName.BIGINT),
> > > +            new Column("ws_ship_hdemo_sk", SqlTypeName.BIGINT),
> > > +            new Column("ws_ship_addr_sk", SqlTypeName.BIGINT),
> > > +            new Column("ws_web_page_sk", SqlTypeName.BIGINT),
> > > +            new Column("ws_web_site_sk", SqlTypeName.BIGINT),
> > > +            new Column("ws_ship_mode_sk", SqlTypeName.BIGINT),
> > > +            new Column("ws_warehouse_sk", SqlTypeName.BIGINT),
> > > +            new Column("ws_promo_sk", SqlTypeName.BIGINT),
> > > +            new Column("ws_order_number", SqlTypeName.BIGINT),
> > > +            new Column("ws_quantity", SqlTypeName.BIGINT),
> > > +            new Column("ws_wholesale_cost", SqlTypeName.DOUBLE),
> > > +            new Column("ws_list_price", SqlTypeName.DOUBLE),
> > > +            new Column("ws_sales_price", SqlTypeName.DOUBLE),
> > > +            new Column("ws_ext_discount_amt", SqlTypeName.DOUBLE),
> > > +            new Column("ws_ext_sales_price", SqlTypeName.DOUBLE),
> > > +            new Column("ws_ext_wholesale_cost", SqlTypeName.DOUBLE),
> > > +            new Column("ws_ext_list_price", SqlTypeName.DOUBLE),
> > > +            new Column("ws_ext_tax", SqlTypeName.DOUBLE),
> > > +            new Column("ws_coupon_amt", SqlTypeName.DOUBLE),
> > > +            new Column("ws_ext_ship_cost", SqlTypeName.DOUBLE),
> > > +            new Column("ws_net_paid", SqlTypeName.DOUBLE),
> > > +            new Column("ws_net_paid_inc_tax", SqlTypeName.DOUBLE),
> > > +            new Column("ws_net_paid_inc_ship", SqlTypeName.DOUBLE),
> > > +            new Column("ws_net_paid_inc_ship_tax",
> SqlTypeName.DOUBLE),
> > > +            new Column("ws_net_profit", SqlTypeName.DOUBLE)));
> > > +    schema.add(
> > > +        "web_returns",
> > > +        new Table(
> > > +            typeFactory,
> > > +            new Column("wr_returned_date_sk", SqlTypeName.BIGINT),
> > > +            new Column("wr_returned_time_sk", SqlTypeName.BIGINT),
> > > +            new Column("wr_item_sk", SqlTypeName.BIGINT),
> > > +            new Column("wr_refunded_customer_sk", SqlTypeName.BIGINT),
> > > +            new Column("wr_refunded_cdemo_sk", SqlTypeName.BIGINT),
> > > +            new Column("wr_refunded_hdemo_sk", SqlTypeName.BIGINT),
> > > +            new Column("wr_refunded_addr_sk", SqlTypeName.BIGINT),
> > > +            new Column("wr_returning_customer_sk",
> SqlTypeName.BIGINT),
> > > +            new Column("wr_returning_cdemo_sk", SqlTypeName.BIGINT),
> > > +            new Column("wr_returning_hdemo_sk", SqlTypeName.BIGINT),
> > > +            new Column("wr_returning_addr_sk", SqlTypeName.BIGINT),
> > > +            new Column("wr_web_page_sk", SqlTypeName.BIGINT),
> > > +            new Column("wr_reason_sk", SqlTypeName.BIGINT),
> > > +            new Column("wr_order_number", SqlTypeName.BIGINT),
> > > +            new Column("wr_return_quantity", SqlTypeName.BIGINT),
> > > +            new Column("wr_return_amt", SqlTypeName.DOUBLE),
> > > +            new Column("wr_return_tax", SqlTypeName.DOUBLE),
> > > +            new Column("wr_return_amt_inc_tax", SqlTypeName.DOUBLE),
> > > +            new Column("wr_fee", SqlTypeName.DOUBLE),
> > > +            new Column("wr_return_ship_cost", SqlTypeName.DOUBLE),
> > > +            new Column("wr_refunded_cash", SqlTypeName.DOUBLE),
> > > +            new Column("wr_reversed_charge", SqlTypeName.DOUBLE),
> > > +            new Column("wr_account_credit", SqlTypeName.DOUBLE),
> > > +            new Column("wr_net_loss", SqlTypeName.DOUBLE)));
> > > +    schema.add(
> > > +        "call_center",
> > > +        new Table(
> > > +            typeFactory,
> > > +            new Column("cc_call_center_sk", SqlTypeName.BIGINT),
> > > +            new Column("cc_call_center_id", SqlTypeName.VARCHAR),
> > > +            new Column("cc_rec_start_date", SqlTypeName.DATE),
> > > +            new Column("cc_rec_end_date", SqlTypeName.DATE),
> > > +            new Column("cc_closed_date_sk", SqlTypeName.BIGINT),
> > > +            new Column("cc_open_date_sk", SqlTypeName.BIGINT),
> > > +            new Column("cc_name", SqlTypeName.VARCHAR),
> > > +            new Column("cc_class", SqlTypeName.VARCHAR),
> > > +            new Column("cc_employees", SqlTypeName.BIGINT),
> > > +            new Column("cc_sq_ft", SqlTypeName.BIGINT),
> > > +            new Column("cc_hours", SqlTypeName.VARCHAR),
> > > +            new Column("cc_manager", SqlTypeName.VARCHAR),
> > > +            new Column("cc_mkt_id", SqlTypeName.BIGINT),
> > > +            new Column("cc_mkt_class", SqlTypeName.VARCHAR),
> > > +            new Column("cc_mkt_desc", SqlTypeName.VARCHAR),
> > > +            new Column("cc_market_manager", SqlTypeName.VARCHAR),
> > > +            new Column("cc_division", SqlTypeName.BIGINT),
> > > +            new Column("cc_division_name", SqlTypeName.VARCHAR),
> > > +            new Column("cc_company", SqlTypeName.BIGINT),
> > > +            new Column("cc_company_name", SqlTypeName.VARCHAR),
> > > +            new Column("cc_street_number", SqlTypeName.VARCHAR),
> > > +            new Column("cc_street_name", SqlTypeName.VARCHAR),
> > > +            new Column("cc_street_type", SqlTypeName.VARCHAR),
> > > +            new Column("cc_suite_number", SqlTypeName.VARCHAR),
> > > +            new Column("cc_city", SqlTypeName.VARCHAR),
> > > +            new Column("cc_county", SqlTypeName.VARCHAR),
> > > +            new Column("cc_state", SqlTypeName.VARCHAR),
> > > +            new Column("cc_zip", SqlTypeName.VARCHAR),
> > > +            new Column("cc_country", SqlTypeName.VARCHAR),
> > > +            new Column("cc_gmt_offset", SqlTypeName.DOUBLE),
> > > +            new Column("cc_tax_percentage", SqlTypeName.DOUBLE)));
> > > +    schema.add(
> > > +        "catalog_page",
> > > +        new Table(
> > > +            typeFactory,
> > > +            new Column("cp_catalog_page_sk", SqlTypeName.BIGINT),
> > > +            new Column("cp_catalog_page_id", SqlTypeName.VARCHAR),
> > > +            new Column("cp_start_date_sk", SqlTypeName.BIGINT),
> > > +            new Column("cp_end_date_sk", SqlTypeName.BIGINT),
> > > +            new Column("cp_department", SqlTypeName.VARCHAR),
> > > +            new Column("cp_catalog_number", SqlTypeName.BIGINT),
> > > +            new Column("cp_catalog_page_number", SqlTypeName.BIGINT),
> > > +            new Column("cp_description", SqlTypeName.VARCHAR),
> > > +            new Column("cp_type", SqlTypeName.VARCHAR)));
> > > +    schema.add(
> > > +        "customer",
> > > +        new Table(
> > > +            typeFactory,
> > > +            new Column("c_customer_sk", SqlTypeName.BIGINT),
> > > +            new Column("c_customer_id", SqlTypeName.VARCHAR),
> > > +            new Column("c_current_cdemo_sk", SqlTypeName.BIGINT),
> > > +            new Column("c_current_hdemo_sk", SqlTypeName.BIGINT),
> > > +            new Column("c_current_addr_sk", SqlTypeName.BIGINT),
> > > +            new Column("c_first_shipto_date_sk", SqlTypeName.BIGINT),
> > > +            new Column("c_first_sales_date_sk", SqlTypeName.BIGINT),
> > > +            new Column("c_salutation", SqlTypeName.VARCHAR),
> > > +            new Column("c_first_name", SqlTypeName.VARCHAR),
> > > +            new Column("c_last_name", SqlTypeName.VARCHAR),
> > > +            new Column("c_preferred_cust_flag", SqlTypeName.VARCHAR),
> > > +            new Column("c_birth_day", SqlTypeName.BIGINT),
> > > +            new Column("c_birth_month", SqlTypeName.BIGINT),
> > > +            new Column("c_birth_year", SqlTypeName.BIGINT),
> > > +            new Column("c_birth_country", SqlTypeName.VARCHAR),
> > > +            new Column("c_login", SqlTypeName.VARCHAR),
> > > +            new Column("c_email_address", SqlTypeName.VARCHAR),
> > > +            new Column("c_last_review_date_sk", SqlTypeName.BIGINT)));
> > > +    schema.add(
> > > +        "customer_address",
> > > +        new Table(
> > > +            typeFactory,
> > > +            new Column("ca_address_sk", SqlTypeName.BIGINT),
> > > +            new Column("ca_address_id", SqlTypeName.VARCHAR),
> > > +            new Column("ca_street_number", SqlTypeName.VARCHAR),
> > > +            new Column("ca_street_name", SqlTypeName.VARCHAR),
> > > +            new Column("ca_street_type", SqlTypeName.VARCHAR),
> > > +            new Column("ca_suite_number", SqlTypeName.VARCHAR),
> > > +            new Column("ca_city", SqlTypeName.VARCHAR),
> > > +            new Column("ca_county", SqlTypeName.VARCHAR),
> > > +            new Column("ca_state", SqlTypeName.VARCHAR),
> > > +            new Column("ca_zip", SqlTypeName.VARCHAR),
> > > +            new Column("ca_country", SqlTypeName.VARCHAR),
> > > +            new Column("ca_gmt_offset", SqlTypeName.DOUBLE),
> > > +            new Column("ca_location_type", SqlTypeName.VARCHAR)));
> > > +    schema.add(
> > > +        "customer_demographics",
> > > +        new Table(
> > > +            typeFactory,
> > > +            new Column("cd_demo_sk", SqlTypeName.BIGINT),
> > > +            new Column("cd_gender", SqlTypeName.VARCHAR),
> > > +            new Column("cd_marital_status", SqlTypeName.VARCHAR),
> > > +            new Column("cd_education_status", SqlTypeName.VARCHAR),
> > > +            new Column("cd_purchase_estimate", SqlTypeName.BIGINT),
> > > +            new Column("cd_credit_rating", SqlTypeName.VARCHAR),
> > > +            new Column("cd_dep_count", SqlTypeName.BIGINT),
> > > +            new Column("cd_dep_employed_count", SqlTypeName.BIGINT),
> > > +            new Column("cd_dep_college_count", SqlTypeName.BIGINT)));
> > > +    schema.add(
> > > +        "date_dim",
> > > +        new Table(
> > > +            typeFactory,
> > > +            new Column("d_date_sk", SqlTypeName.BIGINT),
> > > +            new Column("d_date_id", SqlTypeName.VARCHAR),
> > > +            new Column("d_date", SqlTypeName.DATE),
> > > +            new Column("d_month_seq", SqlTypeName.BIGINT),
> > > +            new Column("d_week_seq", SqlTypeName.BIGINT),
> > > +            new Column("d_quarter_seq", SqlTypeName.BIGINT),
> > > +            new Column("d_year", SqlTypeName.BIGINT),
> > > +            new Column("d_dow", SqlTypeName.BIGINT),
> > > +            new Column("d_moy", SqlTypeName.BIGINT),
> > > +            new Column("d_dom", SqlTypeName.BIGINT),
> > > +            new Column("d_qoy", SqlTypeName.BIGINT),
> > > +            new Column("d_fy_year", SqlTypeName.BIGINT),
> > > +            new Column("d_fy_quarter_seq", SqlTypeName.BIGINT),
> > > +            new Column("d_fy_week_seq", SqlTypeName.BIGINT),
> > > +            new Column("d_day_name", SqlTypeName.VARCHAR),
> > > +            new Column("d_quarter_name", SqlTypeName.VARCHAR),
> > > +            new Column("d_holiday", SqlTypeName.VARCHAR),
> > > +            new Column("d_weekend", SqlTypeName.VARCHAR),
> > > +            new Column("d_following_holiday", SqlTypeName.VARCHAR),
> > > +            new Column("d_first_dom", SqlTypeName.BIGINT),
> > > +            new Column("d_last_dom", SqlTypeName.BIGINT),
> > > +            new Column("d_same_day_ly", SqlTypeName.BIGINT),
> > > +            new Column("d_same_day_lq", SqlTypeName.BIGINT),
> > > +            new Column("d_current_day", SqlTypeName.VARCHAR),
> > > +            new Column("d_current_week", SqlTypeName.VARCHAR),
> > > +            new Column("d_current_month", SqlTypeName.VARCHAR),
> > > +            new Column("d_current_quarter", SqlTypeName.VARCHAR),
> > > +            new Column("d_current_year", SqlTypeName.VARCHAR)));
> > > +    schema.add(
> > > +        "household_demographics",
> > > +        new Table(
> > > +            typeFactory,
> > > +            new Column("hd_demo_sk", SqlTypeName.BIGINT),
> > > +            new Column("hd_income_band_sk", SqlTypeName.BIGINT),
> > > +            new Column("hd_buy_potential", SqlTypeName.VARCHAR),
> > > +            new Column("hd_dep_count", SqlTypeName.BIGINT),
> > > +            new Column("hd_vehicle_count", SqlTypeName.BIGINT)));
> > > +    schema.add(
> > > +        "income_band",
> > > +        new Table(
> > > +            typeFactory,
> > > +            new Column("ib_income_band_sk", SqlTypeName.BIGINT),
> > > +            new Column("ib_lower_bound", SqlTypeName.BIGINT),
> > > +            new Column("ib_upper_bound", SqlTypeName.BIGINT)));
> > > +    schema.add(
> > > +        "item",
> > > +        new Table(
> > > +            typeFactory,
> > > +            new Column("i_item_sk", SqlTypeName.BIGINT),
> > > +            new Column("i_item_id", SqlTypeName.VARCHAR),
> > > +            new Column("i_rec_start_date", SqlTypeName.DATE),
> > > +            new Column("i_rec_end_date", SqlTypeName.DATE),
> > > +            new Column("i_item_desc", SqlTypeName.VARCHAR),
> > > +            new Column("i_current_price", SqlTypeName.DOUBLE),
> > > +            new Column("i_wholesale_cost", SqlTypeName.DOUBLE),
> > > +            new Column("i_brand_id", SqlTypeName.BIGINT),
> > > +            new Column("i_brand", SqlTypeName.VARCHAR),
> > > +            new Column("i_class_id", SqlTypeName.BIGINT),
> > > +            new Column("i_class", SqlTypeName.VARCHAR),
> > > +            new Column("i_category_id", SqlTypeName.BIGINT),
> > > +            new Column("i_category", SqlTypeName.VARCHAR),
> > > +            new Column("i_manufact_id", SqlTypeName.BIGINT),
> > > +            new Column("i_manufact", SqlTypeName.VARCHAR),
> > > +            new Column("i_size", SqlTypeName.VARCHAR),
> > > +            new Column("i_formulation", SqlTypeName.VARCHAR),
> > > +            new Column("i_color", SqlTypeName.VARCHAR),
> > > +            new Column("i_units", SqlTypeName.VARCHAR),
> > > +            new Column("i_container", SqlTypeName.VARCHAR),
> > > +            new Column("i_manager_id", SqlTypeName.BIGINT),
> > > +            new Column("i_product_name", SqlTypeName.VARCHAR)));
> > > +    schema.add(
> > > +        "promotion",
> > > +        new Table(
> > > +            typeFactory,
> > > +            new Column("p_promo_sk", SqlTypeName.BIGINT),
> > > +            new Column("p_promo_id", SqlTypeName.VARCHAR),
> > > +            new Column("p_start_date_sk", SqlTypeName.BIGINT),
> > > +            new Column("p_end_date_sk", SqlTypeName.BIGINT),
> > > +            new Column("p_item_sk", SqlTypeName.BIGINT),
> > > +            new Column("p_cost", SqlTypeName.DOUBLE),
> > > +            new Column("p_response_target", SqlTypeName.BIGINT),
> > > +            new Column("p_promo_name", SqlTypeName.VARCHAR),
> > > +            new Column("p_channel_dmail", SqlTypeName.VARCHAR),
> > > +            new Column("p_channel_email", SqlTypeName.VARCHAR),
> > > +            new Column("p_channel_catalog", SqlTypeName.VARCHAR),
> > > +            new Column("p_channel_tv", SqlTypeName.VARCHAR),
> > > +            new Column("p_channel_radio", SqlTypeName.VARCHAR),
> > > +            new Column("p_channel_press", SqlTypeName.VARCHAR),
> > > +            new Column("p_channel_event", SqlTypeName.VARCHAR),
> > > +            new Column("p_channel_demo", SqlTypeName.VARCHAR),
> > > +            new Column("p_channel_details", SqlTypeName.VARCHAR),
> > > +            new Column("p_purpose", SqlTypeName.VARCHAR),
> > > +            new Column("p_discount_active", SqlTypeName.VARCHAR)));
> > > +    schema.add(
> > > +        "reason",
> > > +        new Table(
> > > +            typeFactory,
> > > +            new Column("r_reason_sk", SqlTypeName.BIGINT),
> > > +            new Column("r_reason_id", SqlTypeName.VARCHAR),
> > > +            new Column("r_reason_desc", SqlTypeName.VARCHAR)));
> > > +    schema.add(
> > > +        "ship_mode",
> > > +        new Table(
> > > +            typeFactory,
> > > +            new Column("sm_ship_mode_sk", SqlTypeName.BIGINT),
> > > +            new Column("sm_ship_mode_id", SqlTypeName.VARCHAR),
> > > +            new Column("sm_type", SqlTypeName.VARCHAR),
> > > +            new Column("sm_code", SqlTypeName.VARCHAR),
> > > +            new Column("sm_carrier", SqlTypeName.VARCHAR),
> > > +            new Column("sm_contract", SqlTypeName.VARCHAR)));
> > > +    schema.add(
> > > +        "store",
> > > +        new Table(
> > > +            typeFactory,
> > > +            new Column("s_store_sk", SqlTypeName.BIGINT),
> > > +            new Column("s_store_id", SqlTypeName.VARCHAR),
> > > +            new Column("s_rec_start_date", SqlTypeName.DATE),
> > > +            new Column("s_rec_end_date", SqlTypeName.DATE),
> > > +            new Column("s_closed_date_sk", SqlTypeName.BIGINT),
> > > +            new Column("s_store_name", SqlTypeName.VARCHAR),
> > > +            new Column("s_number_employees", SqlTypeName.BIGINT),
> > > +            new Column("s_floor_space", SqlTypeName.BIGINT),
> > > +            new Column("s_hours", SqlTypeName.VARCHAR),
> > > +            new Column("s_manager", SqlTypeName.VARCHAR),
> > > +            new Column("s_market_id", SqlTypeName.BIGINT),
> > > +            new Column("s_geography_class", SqlTypeName.VARCHAR),
> > > +            new Column("s_market_desc", SqlTypeName.VARCHAR),
> > > +            new Column("s_market_manager", SqlTypeName.VARCHAR),
> > > +            new Column("s_division_id", SqlTypeName.BIGINT),
> > > +            new Column("s_division_name", SqlTypeName.VARCHAR),
> > > +            new Column("s_company_id", SqlTypeName.BIGINT),
> > > +            new Column("s_company_name", SqlTypeName.VARCHAR),
> > > +            new Column("s_street_number", SqlTypeName.VARCHAR),
> > > +            new Column("s_street_name", SqlTypeName.VARCHAR),
> > > +            new Column("s_street_type", SqlTypeName.VARCHAR),
> > > +            new Column("s_suite_number", SqlTypeName.VARCHAR),
> > > +            new Column("s_city", SqlTypeName.VARCHAR),
> > > +            new Column("s_county", SqlTypeName.VARCHAR),
> > > +            new Column("s_state", SqlTypeName.VARCHAR),
> > > +            new Column("s_zip", SqlTypeName.VARCHAR),
> > > +            new Column("s_country", SqlTypeName.VARCHAR),
> > > +            new Column("s_gmt_offset", SqlTypeName.DOUBLE),
> > > +            new Column("s_tax_precentage", SqlTypeName.DOUBLE)));
> > > +    schema.add(
> > > +        "time_dim",
> > > +        new Table(
> > > +            typeFactory,
> > > +            new Column("t_time_sk", SqlTypeName.BIGINT),
> > > +            new Column("t_time_id", SqlTypeName.VARCHAR),
> > > +            new Column("t_time", SqlTypeName.BIGINT),
> > > +            new Column("t_hour", SqlTypeName.BIGINT),
> > > +            new Column("t_minute", SqlTypeName.BIGINT),
> > > +            new Column("t_second", SqlTypeName.BIGINT),
> > > +            new Column("t_am_pm", SqlTypeName.VARCHAR),
> > > +            new Column("t_shift", SqlTypeName.VARCHAR),
> > > +            new Column("t_sub_shift", SqlTypeName.VARCHAR),
> > > +            new Column("t_meal_time", SqlTypeName.VARCHAR)));
> > > +    schema.add(
> > > +        "warehouse",
> > > +        new Table(
> > > +            typeFactory,
> > > +            new Column("w_warehouse_sk", SqlTypeName.BIGINT),
> > > +            new Column("w_warehouse_id", SqlTypeName.VARCHAR),
> > > +            new Column("w_warehouse_name", SqlTypeName.VARCHAR),
> > > +            new Column("w_warehouse_sq_ft", SqlTypeName.BIGINT),
> > > +            new Column("w_street_number", SqlTypeName.VARCHAR),
> > > +            new Column("w_street_name", SqlTypeName.VARCHAR),
> > > +            new Column("w_street_type", SqlTypeName.VARCHAR),
> > > +            new Column("w_suite_number", SqlTypeName.VARCHAR),
> > > +            new Column("w_city", SqlTypeName.VARCHAR),
> > > +            new Column("w_county", SqlTypeName.VARCHAR),
> > > +            new Column("w_state", SqlTypeName.VARCHAR),
> > > +            new Column("w_zip", SqlTypeName.VARCHAR),
> > > +            new Column("w_country", SqlTypeName.VARCHAR),
> > > +            new Column("w_gmt_offset", SqlTypeName.DOUBLE)));
> > > +    schema.add(
> > > +        "web_page",
> > > +        new Table(
> > > +            typeFactory,
> > > +            new Column("wp_web_page_sk", SqlTypeName.BIGINT),
> > > +            new Column("wp_web_page_id", SqlTypeName.VARCHAR),
> > > +            new Column("wp_rec_start_date", SqlTypeName.DATE),
> > > +            new Column("wp_rec_end_date", SqlTypeName.DATE),
> > > +            new Column("wp_creation_date_sk", SqlTypeName.BIGINT),
> > > +            new Column("wp_access_date_sk", SqlTypeName.BIGINT),
> > > +            new Column("wp_autogen_flag", SqlTypeName.VARCHAR),
> > > +            new Column("wp_customer_sk", SqlTypeName.BIGINT),
> > > +            new Column("wp_url", SqlTypeName.VARCHAR),
> > > +            new Column("wp_type", SqlTypeName.VARCHAR),
> > > +            new Column("wp_char_count", SqlTypeName.BIGINT),
> > > +            new Column("wp_link_count", SqlTypeName.BIGINT),
> > > +            new Column("wp_image_count", SqlTypeName.BIGINT),
> > > +            new Column("wp_max_ad_count", SqlTypeName.BIGINT)));
> > > +    schema.add(
> > > +        "web_site",
> > > +        new Table(
> > > +            typeFactory,
> > > +            new Column("web_site_sk", SqlTypeName.BIGINT),
> > > +            new Column("web_site_id", SqlTypeName.VARCHAR),
> > > +            new Column("web_rec_start_date", SqlTypeName.DATE),
> > > +            new Column("web_rec_end_date", SqlTypeName.DATE),
> > > +            new Column("web_name", SqlTypeName.VARCHAR),
> > > +            new Column("web_open_date_sk", SqlTypeName.BIGINT),
> > > +            new Column("web_close_date_sk", SqlTypeName.BIGINT),
> > > +            new Column("web_class", SqlTypeName.VARCHAR),
> > > +            new Column("web_manager", SqlTypeName.VARCHAR),
> > > +            new Column("web_mkt_id", SqlTypeName.BIGINT),
> > > +            new Column("web_mkt_class", SqlTypeName.VARCHAR),
> > > +            new Column("web_mkt_desc", SqlTypeName.VARCHAR),
> > > +            new Column("web_market_manager", SqlTypeName.VARCHAR),
> > > +            new Column("web_company_id", SqlTypeName.BIGINT),
> > > +            new Column("web_company_name", SqlTypeName.VARCHAR),
> > > +            new Column("web_street_number", SqlTypeName.VARCHAR),
> > > +            new Column("web_street_name", SqlTypeName.VARCHAR),
> > > +            new Column("web_street_type", SqlTypeName.VARCHAR),
> > > +            new Column("web_suite_number", SqlTypeName.VARCHAR),
> > > +            new Column("web_city", SqlTypeName.VARCHAR),
> > > +            new Column("web_county", SqlTypeName.VARCHAR),
> > > +            new Column("web_state", SqlTypeName.VARCHAR),
> > > +            new Column("web_zip", SqlTypeName.VARCHAR),
> > > +            new Column("web_country", SqlTypeName.VARCHAR),
> > > +            new Column("web_gmt_offset", SqlTypeName.DOUBLE),
> > > +            new Column("web_tax_percentage", SqlTypeName.DOUBLE)));
> > > +    return schema;
> > > +  }
> > > +
> > > +  @Test
> > > +  void processQuery() throws IOException, SqlParseException {
> > > +      JavaTypeFactoryImpl typeFactory = new JavaTypeFactoryImpl();
> > > +      CalciteSchema schema = newTpcdsSchema(typeFactory);
> > > +      String sqlQuery = "select  i_item_id\n" +
> > > +          "      ,i_item_desc\n" +
> > > +          "      ,i_category\n" +
> > > +          "      ,i_class\n" +
> > > +          "      ,i_current_price\n" +
> > > +          "      ,sum(ws_ext_sales_price) as itemrevenue\n" +
> > > +          "
> > ,sum(ws_ext_sales_price)*100/sum(sum(ws_ext_sales_price))
> > > over\n" +
> > > +          "          (partition by i_class) as revenueratio\n" +
> > > +          "from\n" +
> > > +          "  web_sales\n" +
> > > +          "      ,item\n" +
> > > +          "      ,date_dim\n" +
> > > +          "where\n" +
> > > +          "  ws_item_sk = i_item_sk\n" +
> > > +          "    and i_category in ('Sports', 'Books', 'Home')\n" +
> > > +          "    and ws_sold_date_sk = d_date_sk\n" +
> > > +          "  and d_date between cast('1999-02-22' as date)\n" +
> > > +          "        and (cast('1999-02-22' as date) + INTERVAL '30'
> > day)\n"
> > > +
> > > +          "group by\n" +
> > > +          "  i_item_id\n" +
> > > +          "        ,i_item_desc\n" +
> > > +          "        ,i_category\n" +
> > > +          "        ,i_class\n" +
> > > +          "        ,i_current_price\n" +
> > > +          "order by\n" +
> > > +          "  i_category\n" +
> > > +          "        ,i_class\n" +
> > > +          "        ,i_item_id\n" +
> > > +          "        ,i_item_desc\n" +
> > > +          "        ,revenueratio\n" +
> > > +          "limit 100";
> > > +    System.out.println(sqlQuery);
> > > +
> > > +    SqlParser parser = SqlParser.create(
> > > +        sqlQuery,
> > > SqlParser.Config.DEFAULT.withQuoting(Quoting.BACK_TICK));
> > > +    SqlNode sqlNode = parser.parseQuery();
> > > +
> > > +    // 3> Validate the query
> > > +    CalciteCatalogReader catalogReader = new CalciteCatalogReader(
> > > +        schema,
> > > +        Collections.emptyList(),
> > > +        typeFactory,
> > > +        CalciteConnectionConfig.DEFAULT.set(
> > > +            CalciteConnectionProperty.CASE_SENSITIVE, "false"));
> > > +    SqlValidator validator = SqlValidatorUtil.newValidator(
> > > +        SqlStdOperatorTable.instance(),
> > > +        catalogReader,
> > > +        typeFactory,
> > > +        SqlValidator.Config.DEFAULT);
> > > +    sqlNode = validator.validate(sqlNode);
> > > +
> > > +    // 4> Convert the query into logical plan.
> > > +    VolcanoPlanner planner = new VolcanoPlanner();
> > > +    planner.addRelTraitDef(ConventionTraitDef.INSTANCE);
> > > +    RelOptCluster cluster =
> > > +        RelOptCluster.create(planner, new RexBuilder(typeFactory));
> > > +    SqlToRelConverter relConverter = new SqlToRelConverter(
> > > +        new RelOptTable.ViewExpander() {  // no-op expander
> > > +          @Override
> > > +          public RelRoot expandView(
> > > +              final RelDataType rowType,
> > > +              final String queryString,
> > > +              final List<String> schemaPath,
> > > +              final List<String> viewPath) {
> > > +            return null;
> > > +          }
> > > +        },
> > > +        validator,
> > > +        catalogReader,
> > > +        cluster,
> > > +        StandardConvertletTable.INSTANCE,
> > > +        SqlToRelConverter.config());
> > > +    RelNode logicalPlan = relConverter.convertQuery(sqlNode, false,
> > > true).rel;
> > > +    System.out.println(RelOptUtil.dumpPlan(
> > > +        "[Initial Logical Plan]",
> > > +        logicalPlan,
> > > +        SqlExplainFormat.TEXT,
> > > +        SqlExplainLevel.EXPPLAN_ATTRIBUTES));
> > > +    logicalPlan = relConverter.decorrelate(sqlNode, logicalPlan);
> > > +    System.out.println(RelOptUtil.dumpPlan(
> > > +        "[Decorrelated Logical Plan]",
> > > +        logicalPlan,
> > > +        SqlExplainFormat.TEXT,
> > > +        SqlExplainLevel.EXPPLAN_ATTRIBUTES));
> > > +
> > > +    System.out.println("---");
> > > +  }
> > > +}
> > > +
> > >
> > > On Wed, Feb 24, 2021 at 6:56 AM Priyendra Deshwal <[email protected]
> >
> > > wrote:
> > >
> > > > On Sun, Feb 21, 2021 at 3:50 AM Ruben Q L <[email protected]> wrote:
> > > >
> > > >> Thanks for the feedback.
> > > >>
> > > >> The SUBSTR function is not a SQL standard function, so it requires
> > some
> > > >> specific configuration (specifically the "fun" parameter).
> > > >> Please check
> > > >>
> > >
> >
> https://calcite.apache.org/docs/reference.html#dialect-specific-operators
> > > >> for more info (and notice how SUBSTR is listed in the table in that
> > > >> section).
> > > >> The alternative would be modifying the queries to use the standard
> > > >> SUBSTRING function.
> > > >>
> > > >
> > > > I am unsure how to specify the "fun" parameter. Can you point me to
> > some
> > > > examples. Note that I am not interacting with calcite via some sort
> of
> > > > connection string. I need some programmatic way to enable this
> > behavior.
> > > I
> > > > can certainly modify the query but it is useful for me to use this
> as a
> > > > learning aid for what is possible with Calcite.
> > > >
> > > > I am trying to reproduce the partition query problem within Calcite,
> > but
> > > so
> > > >> far I have not succeeded.
> > > >> I tried adding your query in a test in TpcdsTest.java [1]. SqlToRel
> > > >> conversion seems to run fine (then the query fails at execution time
> > > with
> > > >> "CalciteException: Cannot convert null to long", but that seems a
> > > >> different
> > > >> problem than yours).
> > > >> Could you please try to reproduce the exception with a unit test in
> > > >> Calcite?
> > > >>
> > > >
> > > > The test fails for me on the latest version of master (commit
> > 03e356c65).
> > > > I have attached a patch with this email that contains the failing
> test.
> > > > Here's the stack trace that I am getting:
> > > >
> > > > while converting SUM(`WS_EXT_SALES_PRICE`) * 100 /
> > > > (SUM(SUM(`WS_EXT_SALES_PRICE`)) OVER (PARTITION BY `I_CLASS`))
> > > > java.lang.RuntimeException: while converting
> SUM(`WS_EXT_SALES_PRICE`)
> > *
> > > > 100 / (SUM(SUM(`WS_EXT_SALES_PRICE`)) OVER (PARTITION BY `I_CLASS`))
> > > > at
> > > >
> > >
> >
> org.apache.calcite.sql2rel.ReflectiveConvertletTable.lambda$registerNodeTypeMethod$1(ReflectiveConvertletTable.java:98)
> > > > at
> > > >
> > >
> >
> org.apache.calcite.sql2rel.SqlNodeToRexConverterImpl.convertCall(SqlNodeToRexConverterImpl.java:62)
> > > > at
> > > >
> > >
> >
> org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.visit(SqlToRelConverter.java:5234)
> > > > at
> > > >
> > >
> >
> org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.visit(SqlToRelConverter.java:4488)
> > > > at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:161)
> > > > at
> > > >
> > >
> >
> org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.convertExpression(SqlToRelConverter.java:5090)
> > > > at
> > > >
> > >
> >
> org.apache.calcite.sql2rel.StandardConvertletTable.lambda$new$9(StandardConvertletTable.java:209)
> > > > at
> > > >
> > >
> >
> org.apache.calcite.sql2rel.SqlNodeToRexConverterImpl.convertCall(SqlNodeToRexConverterImpl.java:62)
> > > > at
> > > >
> > >
> >
> org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.visit(SqlToRelConverter.java:5234)
> > > > at
> > > >
> > >
> >
> org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.visit(SqlToRelConverter.java:4488)
> > > > at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:161)
> > > > at
> > > >
> > >
> >
> org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.convertExpression(SqlToRelConverter.java:5090)
> > > > at
> > > >
> > >
> >
> org.apache.calcite.sql2rel.SqlToRelConverter.createAggImpl(SqlToRelConverter.java:3297)
> > > > at
> > > >
> > >
> >
> org.apache.calcite.sql2rel.SqlToRelConverter.convertAgg(SqlToRelConverter.java:3141)
> > > > at
> > > >
> > >
> >
> org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectImpl(SqlToRelConverter.java:702)
> > > > at
> > > >
> > >
> >
> org.apache.calcite.sql2rel.SqlToRelConverter.convertSelect(SqlToRelConverter.java:664)
> > > > at
> > > >
> > >
> >
> org.apache.calcite.sql2rel.SqlToRelConverter.convertQueryRecursive(SqlToRelConverter.java:3538)
> > > > at
> > > >
> > >
> >
> org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:589)
> > > > at
> > > >
> > >
> >
> org.apache.calcite.adapter.tpcds.TpcdsDeshwalTest.processQuery(TpcdsDeshwalTest.java:676)
> > > > at
> > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
> > > > Method)
> > > > at
> > > >
> > >
> >
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> > > > at
> > > >
> > >
> >
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> > > > at java.base/java.lang.reflect.Method.invoke(Method.java:566)
> > > > at
> > > >
> > >
> >
> org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:675)
> > > > at
> > > >
> > >
> >
> org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
> > > > at
> > > >
> > >
> >
> org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:125)
> > > > at
> > > >
> > >
> >
> org.junit.jupiter.engine.extension.TimeoutInvocation.proceed(TimeoutInvocation.java:46)
> > > > at
> > > >
> > >
> >
> org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:139)
> > > > at
> > > >
> > >
> >
> org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:131)
> > > > at
> > > >
> > >
> >
> org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:81)
> > > > at
> > > >
> > >
> >
> org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
> > > > at
> > > >
> > >
> >
> org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
> > > > at
> > > >
> > >
> >
> org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:104)
> > > > at
> > > >
> > >
> >
> org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:62)
> > > > at
> > > >
> > >
> >
> org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:43)
> > > > at
> > > >
> > >
> >
> org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:35)
> > > > at
> > > >
> > >
> >
> org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
> > > > at
> > > >
> > >
> >
> org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
> > > > at
> > > >
> > >
> >
> org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:202)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
> > > > at
> > > >
> > >
> >
> org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:198)
> > > > at
> > > >
> > >
> >
> org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135)
> > > > at
> > > >
> > >
> >
> org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:69)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
> > > > at
> > > >
> > org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService$ExclusiveTask.compute(ForkJoinPoolHierarchicalTestExecutorService.java:171)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService.invokeAll(ForkJoinPoolHierarchicalTestExecutorService.java:115)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
> > > > at
> > > >
> > org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService$ExclusiveTask.compute(ForkJoinPoolHierarchicalTestExecutorService.java:171)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService.invokeAll(ForkJoinPoolHierarchicalTestExecutorService.java:115)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
> > > > at
> > > >
> > org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
> > > > at
> > > >
> > >
> >
> org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService$ExclusiveTask.compute(ForkJoinPoolHierarchicalTestExecutorService.java:171)
> > > > at
> > > >
> > >
> >
> java.base/java.util.concurrent.RecursiveAction.exec(RecursiveAction.java:189)
> > > > at
> > > >
> > java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
> > > > at
> > > >
> > >
> >
> java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
> > > > at
> > >
> java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
> > > > at
> > > >
> > >
> >
> java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
> > > > at
> > > >
> > >
> >
> java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
> > > > Caused by: java.lang.reflect.InvocationTargetException
> > > > at
> > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
> > > > Method)
> > > > at
> > > >
> > >
> >
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> > > > at
> > > >
> > >
> >
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> > > > at java.base/java.lang.reflect.Method.invoke(Method.java:566)
> > > > at
> > > >
> > >
> >
> org.apache.calcite.sql2rel.ReflectiveConvertletTable.lambda$registerNodeTypeMethod$1(ReflectiveConvertletTable.java:93)
> > > > ... 77 more
> > > > Caused by: java.lang.UnsupportedOperationException: class
> > > > org.apache.calcite.sql.SqlBasicCall: SUM(SUM(`WS_EXT_SALES_PRICE`))
> > OVER
> > > > (PARTITION BY `I_CLASS`)
> > > > at org.apache.calcite.util.Util.needToImplement(Util.java:1085)
> > > > at
> > > >
> > >
> >
> org.apache.calcite.sql.validate.SqlValidatorImpl.getValidatedNodeType(SqlValidatorImpl.java:1765)
> > > > at
> > > >
> > >
> >
> org.apache.calcite.sql2rel.SqlToRelConverter.convertOver(SqlToRelConverter.java:2069)
> > > > at
> > > >
> > >
> >
> org.apache.calcite.sql2rel.SqlToRelConverter.access$2000(SqlToRelConverter.java:224)
> > > > at
> > > >
> > >
> >
> org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.convertExpression(SqlToRelConverter.java:5083)
> > > > at
> > > >
> > >
> >
> org.apache.calcite.sql2rel.StandardConvertletTable.convertOperands(StandardConvertletTable.java:960)
> > > > at
> > > >
> > >
> >
> org.apache.calcite.sql2rel.StandardConvertletTable.convertOperands(StandardConvertletTable.java:952)
> > > > at
> > > >
> > >
> >
> org.apache.calcite.sql2rel.StandardConvertletTable.convertCall(StandardConvertletTable.java:915)
> > > > ... 82 more
> > > >
> > > >
> > > >
> > > >
> > >
> >
>

Reply via email to