It appears to be because "getSubSchema" in
"calcite.jdbc.CalciteSchema.SchemaPlusImpl" has a "subSchemaMap" that loses
the "hr" schema and only contains "metadata" [0]

But if I call the same function the map shows "hr" is present [1] which
doesn't make sense to me

[0]: https://imgur.com/djlkBVf
[1]: https://imgur.com/eEOvjdS







On Fri, Dec 31, 2021 at 5:20 PM Gavin Ray <[email protected]> wrote:

> Unsure of where this is coming from/how to debug it.
> (The code I am using is below, taken from Calcite examples)
>
> If I print out the sub-schema names of "rootSchema", and their tables, I
> get:
>
>     subSchemaNames: [hr, metadata]
>     "hr" subSchema table names: [depts, emps]
>     "metadata" subSchema table names: [COLUMNS, TABLES]
>
> So I am not certain what value is being passed that it would fail
> a "schema.getSubSchema()" call, or where to put a breakpoint to debug that.
>
> Does anyone spot something I'm doing that's clearly wrong, or have an idea
> where I could look to find the code that's causing this?
>
> Stacktrace winds up at "Baz", so I think it's generated code
> Thank you
> ===========================================================
>
> fun main(args: Array<String>) {
>     val hr = Frameworks.createRootSchema(true).add("hr",
> HrClusteredSchema())
>
>     val frameworkConfig: FrameworkConfig = Frameworks
>         .newConfigBuilder()
>         .parserConfig(SqlParser.config().withCaseSensitive(false))
>         .defaultSchema(hr)
>         .build()
>
>     Frameworks.withPlanner(::test, frameworkConfig)
> }
>
> fun test(cluster: RelOptCluster, relOptSchema: RelOptSchema, rootSchema:
> Schema) {
>     val planner = cluster.planner
>     val relBuilder: RelBuilder =
>         RelFactories.LOGICAL_BUILDER.create(cluster, relOptSchema)
>
>     val relRoot: RelNode = // ...
>     val desiredTraits =
> cluster.traitSet().replace(EnumerableConvention.INSTANCE)
>     val newRoot = cluster.planner.changeTraits(relRoot, desiredTraits)
>
>     cluster.planner.root = newRoot
>     val bestExp = cluster.planner.findBestExp()
>     val run = RelRunners.run(bestExp)
>     val resultSet = run.executeQuery()
> }
>

Reply via email to