I have noticed an inconsistency for the following

==========[START model]==========
{
  "version": "1.0",
  "defaultSchema": "foodmart",
  "schemas": [
    {
      "name": "foodmart",
      "type": "custom",
      "factory": "example.Factory",
      "operand": {
        "tables": [
          {
            "file": "product_class.json"
          },
          {
            "file": "product.json"
          },
          {
            "file": "sales_fact_1997.json"
          },
          {
            "file": "time_by_day.json"
          }
        ]
      },
      "lattices": [
        {
          "name": "star",
          "sql": [
            "select 1 from \"foodmart\".\"sales_fact_1997\" as \"s\"",
            "join \"foodmart\".\"product\" as \"p\" using (\"product_id\")",
            "join \"foodmart\".\"time_by_day\" as \"t\" using
(\"time_id\")",
            "join \"foodmart\".\"product_class\" as \"pc\" on
\"p\".\"product_class_id\" = \"pc\".\"product_class_id\""
          ],
          "auto": false,
          "algorithm": true,
          "rowCountEstimate": 86837,
          "defaultMeasures": [
            {
              "agg": "count"
            }
          ],
          "tiles": [
            {
              "dimensions": [
                "the_year",
                [
                  "t",
                  "quarter"
                ]
              ],
              "measures": [
                {
                  "agg": "sum",
                  "args": "unit_sales"
                },
                {
                  "agg": "sum",
                  "args": "store_sales"
                },
                {
                  "agg": "count"
                }
              ]
            }
          ]
        }
      ],
      "tables": [
        {
          "name": "v_sales_fact_1997",
          "type": "view",
          "sql": "select product_id, customer_id from
foodmart.sales_fact_1997 where product_id=123",
          "modifiable": false
        }
      ]
    }
  ]
}
==========[END model]==========
==========[START happy path]==========
        FrameworkConfig frameworkConfig = Frameworks.newConfigBuilder()
            .parserConfig(
                SqlParser.config()
                .withCaseSensitive(false)
                .withUnquotedCasing(Casing.UNCHANGED)
                .withLex(Lex.JAVA)
            )

.defaultSchema(connection.getRootSchema().getSubSchema(connection.getSchema()))
            .build();
        Planner planner = Frameworks.getPlanner(frameworkConfig);
// THIS WORKS
// ===>        String sqlInput = "select customer_id, product_name from
foodmart.star";
        System.out.println("\nInput SQL is: \n"+sqlInput);
        SqlNode sqlNodeInput = planner.parse(sqlInput);
        SqlNode sqlNodeInputValidated = planner.validate(sqlNodeInput);
==========[END happy path]==========
==========[START unhappy path]==========
        FrameworkConfig frameworkConfig = Frameworks.newConfigBuilder()
            .parserConfig(
                SqlParser.config()
                .withCaseSensitive(false)
                .withUnquotedCasing(Casing.UNCHANGED)
                .withLex(Lex.JAVA)
            )

.defaultSchema(connection.getRootSchema().getSubSchema(connection.getSchema()))
            .build();
        Planner planner = Frameworks.getPlanner(frameworkConfig);
// THIS FAILS
// ===>        String sqlInput = "select customer_id, product_name from
foodmart.v_sales_fact_1997";
        System.out.println("\nInput SQL is: \n"+sqlInput);
        SqlNode sqlNodeInput = planner.parse(sqlInput);
        SqlNode sqlNodeInputValidated = planner.validate(sqlNodeInput);
==========[END unhappy path]==========

The error is as follows:
Exception in thread "main" org.apache.calcite.tools.ValidationException:
org.apache.calcite.runtime.CalciteContextException: From line 1, column 37
to line 1, column 60: Object 'FOODMART' not found; did you mean 'foodmart'?

Why does parsing a query for a view get converted to uppercase, while
parsing a query for a lattice does not get converted to uppercase? I
believe this is a mistake as both entities should be treated the same.

From,
Hugh Pearse

Reply via email to