Also if it is helpful, there is a class in Calcite called "SqlTypeName"
that has a "Map<JdbcType, SqlType>" and a function "getNameForJdbcType(int
ordinal)"

https://github.com/apache/calcite/blob/812e3e98eae518cf85cd1b6b7f055fb96784a423/core/src/main/java/org/apache/calcite/sql/type/SqlTypeName.java#L215-L256

There is also "SqlTypeFamily" which is useful if you don't care about
individual types but just the overall type family.

I use these a lot in my project
Hope this is useful =)


On Thu, Feb 24, 2022 at 9:13 AM Stamatis Zampetakis <zabe...@gmail.com>
wrote:

> The JDBC specification [1] defines the mapping between JDBC/SQL types to
> Java types (check TABLE B-1 JDBC Types Mapped to Java Types).
>
> Best,
> Stamatis
>
> [1] https://jcp.org/aboutJava/communityprocess/mrel/jsr221/index3.html
>
> On Thu, Feb 24, 2022 at 1:48 PM xiaobo <guxiaobo1...@qq.com.invalid>
> wrote:
>
> > What we want to do is mapping Java LocalTime to SQL Time, from the csv
> > adapter example we know that we should pass a long value for SQL Time,
> but
> > we can't convert a Java LocalTime to Java Date to call it's getTime
> method
> > like the CSV adapter, then what value should we calculate from  Java
> > LocalTime  for SQL Time.
> >
> >
> >
> >
> > ------------------ Original ------------------
> > From:  "xiaobo ";<guxiaobo1...@qq.com>;
> > Send time: Thursday, Feb 24, 2022 12:26 PM
> > To: "dev"<dev@calcite.apache.org>;
> >
> > Subject:  Re: dynamic reflective schema
> >
> >
> >
> > our adapter now supports
> > string,boolean,bigdecimal,long,localdate,localdatetime, and we want to
> > support localtime too, what value should we convert from localtime data ,
> > the total seconds since the start of a day?
> >
> >
> > ---Original---
> > From: "xiaobo "<guxiaobo1...@qq.com>
> > Date: Thu, Feb 24, 2022 12:20 PM
> > To: "dev"<dev@calcite.apache.org>;
> > Subject: Re: dynamic reflective schema
> >
> > yes, we call the
> > getRowType(RelDataTypeFactory typeFactory) method in scan method , is
> this
> > the correct way?
> >
> >
> >
> > ---Original---
> > From: "Gavin Ray"<ray.gavi...@gmail.com>
> > Date: Thu, Feb 24, 2022 00:21 AM
> > To: "dev"<dev@calcite.apache.org>;
> > Subject: Re: dynamic reflective schema
> >
> > Xiabo,
> >
> > Your code seems to work for me, I ran the test case and it passes, see
> the
> > image below:
> > https://i.imgur.com/D0ajyQH.png
> >
> >
> > On Wed, Feb 23, 2022 at 2:33 AM xiaobo <guxiaobo1...@qq.com.invalid>
> > wrote:
> >
> > > we have put the test coding on github
> > >
> > >
> > >
> >
> https://github.com/guxiaobo/calcite-json-adapter/tree/main/src/test/java/org/apache/calcite/adapter/json/test
> > >
> > >
> > >
> > >
> > >
> > > ------------------ Original ------------------
> > > From:  "xiaobo ";<guxiaobo1...@qq.com>;
> > > Send time: Wednesday, Feb 23, 2022 3:11 PM
> > > To: "dev"<dev@calcite.apache.org>;
> > >
> > > Subject:  Re:  dynamic reflective schema
> > >
> > >
> > >
> > > here is the full output with calcite.debug=true, we know the problem is
> > > because the  getRowType(RelDataTypeFactory typeFactory) method is not
> > > called by the framework, but don't know why.
> > >
> > >
> > > 2022-02-23 15:02:42.228  INFO 78585 --- [           main]
> > > c.x.javatest.JavaTestApplication         : Starting JavaTestApplication
> > > using Java 11.0.13 on LindadeMacBook-Air.local with PID 78585
> > >
> >
> (/Users/linda/Documents/Github/sw-smart-risk/sw-pbcm/sw-pbcm-test/java-test-proj/target/classes
> > > started by linda in
> > >
> >
> /Users/linda/Documents/Github/sw-smart-risk/sw-pbcm/sw-pbcm-test/java-test-proj)
> > > 2022-02-23 15:02:42.234  INFO 78585 --- [           main]
> > > c.x.javatest.JavaTestApplication         : No active profile set,
> falling
> > > back to default profiles: default
> > > 2022-02-23 15:02:43.230  WARN 78585 --- [           main]
> > > o.m.s.mapper.ClassPathMapperScanner      : No MyBatis mapper was found
> in
> > > '[com.xsmartware.javatest]' package. Please check your configuration.
> > > 2022-02-23 15:02:44.064  INFO 78585 --- [           main]
> > > o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with
> > port(s):
> > > 8080 (http)
> > > 2022-02-23 15:02:44.082  INFO 78585 --- [           main]
> > > o.apache.catalina.core.StandardService   : Starting service [Tomcat]
> > > 2022-02-23 15:02:44.082  INFO 78585 --- [           main]
> > > org.apache.catalina.core.StandardEngine  : Starting Servlet engine:
> > [Apache
> > > Tomcat/9.0.56]
> > > 2022-02-23 15:02:44.291  INFO 78585 --- [           main]
> > > o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded
> > > WebApplicationContext
> > > 2022-02-23 15:02:44.292  INFO 78585 --- [           main]
> > > w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext:
> > > initialization completed in 1970 ms
> > > 2022-02-23 15:02:45.374  INFO 78585 --- [           main]
> > > o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s):
> > 8080
> > > (http) with context path ''
> > > 2022-02-23 15:02:45.393  INFO 78585 --- [           main]
> > > c.x.javatest.JavaTestApplication         : Started JavaTestApplication
> in
> > > 3.77 seconds (JVM running for 5.146)
> > > /*
> > >  * Licensed to the Apache Software Foundation (ASF) under one or more
> > >  * contributor license agreements.  See the NOTICE file distributed
> with
> > >  * this work for additional information regarding copyright ownership.
> > >  * The ASF licenses this file to you under the Apache License, Version
> > 2.0
> > >  * (the "License"); you may not use this file except in compliance with
> > >  * the License.  You may obtain a copy of the License at
> > >  *
> > >  * http://www.apache.org/licenses/LICENSE-2.0
> > >  *
> > >  * Unless required by applicable law or agreed to in writing, software
> > >  * distributed under the License is distributed on an "AS IS" BASIS,
> > >  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> > implied.
> > >  * See the License for the specific language governing permissions and
> > >  * limitations under the License.
> > >  */
> > > package org.apache.calcite.rel.metadata.janino;
> > >
> > > public final class GeneratedMetadata_CollationHandler
> > >   implements
> > > org.apache.calcite.rel.metadata.BuiltInMetadata.Collation.Handler {
> > >   private final Object methodKey0 =
> > >       new
> > >
> org.apache.calcite.rel.metadata.janino.DescriptiveCacheKey("ImmutableList
> > > Handler.collations()");
> > >   public final org.apache.calcite.rel.metadata.RelMdCollation
> provider0;
> > >   public GeneratedMetadata_CollationHandler(
> > >       org.apache.calcite.rel.metadata.RelMdCollation provider0) {
> > >     this.provider0 = provider0;
> > >   }
> > >   public org.apache.calcite.rel.metadata.MetadataDef getDef() {
> > >     return provider0.getDef();
> > >   }
> > >   public com.google.common.collect.ImmutableList collations(
> > >       org.apache.calcite.rel.RelNode r,
> > >       org.apache.calcite.rel.metadata.RelMetadataQuery mq) {
> > >     while (r instanceof
> > > org.apache.calcite.rel.metadata.DelegatingMetadataRel) {
> > >       r = ((org.apache.calcite.rel.metadata.DelegatingMetadataRel)
> > > r).getMetadataDelegateRel();
> > >     }
> > >     final Object key;
> > >     key = methodKey0;
> > >     final Object v = mq.map.get(r, key);
> > >     if (v != null) {
> > >       if (v == org.apache.calcite.rel.metadata.NullSentinel.ACTIVE) {
> > >         throw new
> > > org.apache.calcite.rel.metadata.CyclicMetadataException();
> > >       }
> > >       if (v == org.apache.calcite.rel.metadata.NullSentinel.INSTANCE) {
> > >         return null;
> > >       }
> > >       return (com.google.common.collect.ImmutableList) v;
> > >     }
> > >     mq.map.put(r,
> > key,org.apache.calcite.rel.metadata.NullSentinel.ACTIVE);
> > >     try {
> > >       final com.google.common.collect.ImmutableList x = collations_(r,
> > mq);
> > >       mq.map.put(r, key,
> > > org.apache.calcite.rel.metadata.NullSentinel.mask(x));
> > >       return x;
> > >     } catch (java.lang.Exception e) {
> > >       mq.map.row(r).clear();
> > >       throw e;
> > >     }
> > >   }
> > >
> > >   private com.google.common.collect.ImmutableList collations_(
> > >       org.apache.calcite.rel.RelNode r,
> > >       org.apache.calcite.rel.metadata.RelMetadataQuery mq) {
> > >     if (r instanceof
> > > org.apache.calcite.adapter.enumerable.EnumerableCorrelate) {
> > >       return
> > >
> >
> provider0.collations((org.apache.calcite.adapter.enumerable.EnumerableCorrelate)
> > > r, mq);
> > >     } else if (r instanceof
> > > org.apache.calcite.adapter.enumerable.EnumerableHashJoin) {
> > >       return
> > >
> >
> provider0.collations((org.apache.calcite.adapter.enumerable.EnumerableHashJoin)
> > > r, mq);
> > >     } else if (r instanceof
> > > org.apache.calcite.adapter.enumerable.EnumerableMergeJoin) {
> > >       return
> > >
> >
> provider0.collations((org.apache.calcite.adapter.enumerable.EnumerableMergeJoin)
> > > r, mq);
> > >     } else if (r instanceof
> > > org.apache.calcite.adapter.enumerable.EnumerableMergeUnion) {
> > >       return
> > >
> >
> provider0.collations((org.apache.calcite.adapter.enumerable.EnumerableMergeUnion)
> > > r, mq);
> > >     } else if (r instanceof
> > > org.apache.calcite.adapter.enumerable.EnumerableNestedLoopJoin) {
> > >       return
> > >
> >
> provider0.collations((org.apache.calcite.adapter.enumerable.EnumerableNestedLoopJoin)
> > > r, mq);
> > >     } else if (r instanceof
> > > org.apache.calcite.adapter.jdbc.JdbcToEnumerableConverter) {
> > >       return
> > >
> >
> provider0.collations((org.apache.calcite.adapter.jdbc.JdbcToEnumerableConverter)
> > > r, mq);
> > >     } else if (r instanceof org.apache.calcite.plan.hep.HepRelVertex) {
> > >       return
> > > provider0.collations((org.apache.calcite.plan.hep.HepRelVertex) r, mq);
> > >     } else if (r instanceof org.apache.calcite.plan.volcano.RelSubset)
> {
> > >       return
> > > provider0.collations((org.apache.calcite.plan.volcano.RelSubset) r,
> mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Calc) {
> > >       return provider0.collations((org.apache.calcite.rel.core.Calc) r,
> > > mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Filter) {
> > >       return provider0.collations((org.apache.calcite.rel.core.Filter)
> r,
> > > mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Match) {
> > >       return provider0.collations((org.apache.calcite.rel.core.Match)
> r,
> > > mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Project) {
> > >       return provider0.collations((org.apache.calcite.rel.core.Project)
> > r,
> > > mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Sort) {
> > >       return provider0.collations((org.apache.calcite.rel.core.Sort) r,
> > > mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.SortExchange) {
> > >       return
> > > provider0.collations((org.apache.calcite.rel.core.SortExchange) r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.TableModify) {
> > >       return
> > > provider0.collations((org.apache.calcite.rel.core.TableModify) r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.TableScan) {
> > >       return
> provider0.collations((org.apache.calcite.rel.core.TableScan)
> > > r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Values) {
> > >       return provider0.collations((org.apache.calcite.rel.core.Values)
> r,
> > > mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Window) {
> > >       return provider0.collations((org.apache.calcite.rel.core.Window)
> r,
> > > mq);
> > >     } else if (r instanceof org.apache.calcite.rel.RelNode) {
> > >       return provider0.collations((org.apache.calcite.rel.RelNode) r,
> > mq);
> > >     } else {
> > >             throw new java.lang.IllegalArgumentException("No handler
> for
> > > method [public abstract com.google.common.collect.ImmutableList
> > >
> >
> org.apache.calcite.rel.metadata.BuiltInMetadata$Collation$Handler.collations(org.apache.calcite.rel.RelNode,org.apache.calcite.rel.metadata.RelMetadataQuery)]
> > > applied to argument of type [" + r.getClass() + "]; we recommend you
> > create
> > > a catch-all (RelNode) handler");
> > >     }
> > >   }
> > >
> > > }
> > >
> > > /*
> > >  * Licensed to the Apache Software Foundation (ASF) under one or more
> > >  * contributor license agreements.  See the NOTICE file distributed
> with
> > >  * this work for additional information regarding copyright ownership.
> > >  * The ASF licenses this file to you under the Apache License, Version
> > 2.0
> > >  * (the "License"); you may not use this file except in compliance with
> > >  * the License.  You may obtain a copy of the License at
> > >  *
> > >  * http://www.apache.org/licenses/LICENSE-2.0
> > >  *
> > >  * Unless required by applicable law or agreed to in writing, software
> > >  * distributed under the License is distributed on an "AS IS" BASIS,
> > >  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> > implied.
> > >  * See the License for the specific language governing permissions and
> > >  * limitations under the License.
> > >  */
> > > package org.apache.calcite.rel.metadata.janino;
> > >
> > > public final class GeneratedMetadata_NonCumulativeCostHandler
> > >   implements
> > >
> >
> org.apache.calcite.rel.metadata.BuiltInMetadata.NonCumulativeCost.Handler {
> > >   private final Object methodKey0 =
> > >       new
> > > org.apache.calcite.rel.metadata.janino.DescriptiveCacheKey("RelOptCost
> > > Handler.getNonCumulativeCost()");
> > >   public final
> > >
> >
> org.apache.calcite.rel.metadata.RelMdPercentageOriginalRows$RelMdNonCumulativeCost
> > > provider0;
> > >   public GeneratedMetadata_NonCumulativeCostHandler(
> > >
> > >
> >
> org.apache.calcite.rel.metadata.RelMdPercentageOriginalRows$RelMdNonCumulativeCost
> > > provider0) {
> > >     this.provider0 = provider0;
> > >   }
> > >   public org.apache.calcite.rel.metadata.MetadataDef getDef() {
> > >     return provider0.getDef();
> > >   }
> > >   public org.apache.calcite.plan.RelOptCost getNonCumulativeCost(
> > >       org.apache.calcite.rel.RelNode r,
> > >       org.apache.calcite.rel.metadata.RelMetadataQuery mq) {
> > >     while (r instanceof
> > > org.apache.calcite.rel.metadata.DelegatingMetadataRel) {
> > >       r = ((org.apache.calcite.rel.metadata.DelegatingMetadataRel)
> > > r).getMetadataDelegateRel();
> > >     }
> > >     final Object key;
> > >     key = methodKey0;
> > >     final Object v = mq.map.get(r, key);
> > >     if (v != null) {
> > >       if (v == org.apache.calcite.rel.metadata.NullSentinel.ACTIVE) {
> > >         throw new
> > > org.apache.calcite.rel.metadata.CyclicMetadataException();
> > >       }
> > >       if (v == org.apache.calcite.rel.metadata.NullSentinel.INSTANCE) {
> > >         return null;
> > >       }
> > >       return (org.apache.calcite.plan.RelOptCost) v;
> > >     }
> > >     mq.map.put(r,
> > key,org.apache.calcite.rel.metadata.NullSentinel.ACTIVE);
> > >     try {
> > >       final org.apache.calcite.plan.RelOptCost x =
> > > getNonCumulativeCost_(r, mq);
> > >       mq.map.put(r, key,
> > > org.apache.calcite.rel.metadata.NullSentinel.mask(x));
> > >       return x;
> > >     } catch (java.lang.Exception e) {
> > >       mq.map.row(r).clear();
> > >       throw e;
> > >     }
> > >   }
> > >
> > >   private org.apache.calcite.plan.RelOptCost getNonCumulativeCost_(
> > >       org.apache.calcite.rel.RelNode r,
> > >       org.apache.calcite.rel.metadata.RelMetadataQuery mq) {
> > >     if (r instanceof org.apache.calcite.rel.RelNode) {
> > >       return
> > > provider0.getNonCumulativeCost((org.apache.calcite.rel.RelNode) r, mq);
> > >     } else {
> > >             throw new java.lang.IllegalArgumentException("No handler
> for
> > > method [public abstract org.apache.calcite.plan.RelOptCost
> > >
> >
> org.apache.calcite.rel.metadata.BuiltInMetadata$NonCumulativeCost$Handler.getNonCumulativeCost(org.apache.calcite.rel.RelNode,org.apache.calcite.rel.metadata.RelMetadataQuery)]
> > > applied to argument of type [" + r.getClass() + "]; we recommend you
> > create
> > > a catch-all (RelNode) handler");
> > >     }
> > >   }
> > >
> > > }
> > >
> > > /*
> > >  * Licensed to the Apache Software Foundation (ASF) under one or more
> > >  * contributor license agreements.  See the NOTICE file distributed
> with
> > >  * this work for additional information regarding copyright ownership.
> > >  * The ASF licenses this file to you under the Apache License, Version
> > 2.0
> > >  * (the "License"); you may not use this file except in compliance with
> > >  * the License.  You may obtain a copy of the License at
> > >  *
> > >  * http://www.apache.org/licenses/LICENSE-2.0
> > >  *
> > >  * Unless required by applicable law or agreed to in writing, software
> > >  * distributed under the License is distributed on an "AS IS" BASIS,
> > >  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> > implied.
> > >  * See the License for the specific language governing permissions and
> > >  * limitations under the License.
> > >  */
> > > package org.apache.calcite.rel.metadata.janino;
> > >
> > > public final class GeneratedMetadata_NodeTypesHandler
> > >   implements
> > > org.apache.calcite.rel.metadata.BuiltInMetadata.NodeTypes.Handler {
> > >   private final Object methodKey0 =
> > >       new
> > > org.apache.calcite.rel.metadata.janino.DescriptiveCacheKey("Multimap
> > > Handler.getNodeTypes()");
> > >   public final org.apache.calcite.rel.metadata.RelMdNodeTypes
> provider0;
> > >   public GeneratedMetadata_NodeTypesHandler(
> > >       org.apache.calcite.rel.metadata.RelMdNodeTypes provider0) {
> > >     this.provider0 = provider0;
> > >   }
> > >   public org.apache.calcite.rel.metadata.MetadataDef getDef() {
> > >     return provider0.getDef();
> > >   }
> > >   public com.google.common.collect.Multimap getNodeTypes(
> > >       org.apache.calcite.rel.RelNode r,
> > >       org.apache.calcite.rel.metadata.RelMetadataQuery mq) {
> > >     while (r instanceof
> > > org.apache.calcite.rel.metadata.DelegatingMetadataRel) {
> > >       r = ((org.apache.calcite.rel.metadata.DelegatingMetadataRel)
> > > r).getMetadataDelegateRel();
> > >     }
> > >     final Object key;
> > >     key = methodKey0;
> > >     final Object v = mq.map.get(r, key);
> > >     if (v != null) {
> > >       if (v == org.apache.calcite.rel.metadata.NullSentinel.ACTIVE) {
> > >         throw new
> > > org.apache.calcite.rel.metadata.CyclicMetadataException();
> > >       }
> > >       if (v == org.apache.calcite.rel.metadata.NullSentinel.INSTANCE) {
> > >         return null;
> > >       }
> > >       return (com.google.common.collect.Multimap) v;
> > >     }
> > >     mq.map.put(r,
> > key,org.apache.calcite.rel.metadata.NullSentinel.ACTIVE);
> > >     try {
> > >       final com.google.common.collect.Multimap x = getNodeTypes_(r,
> mq);
> > >       mq.map.put(r, key,
> > > org.apache.calcite.rel.metadata.NullSentinel.mask(x));
> > >       return x;
> > >     } catch (java.lang.Exception e) {
> > >       mq.map.row(r).clear();
> > >       throw e;
> > >     }
> > >   }
> > >
> > >   private com.google.common.collect.Multimap getNodeTypes_(
> > >       org.apache.calcite.rel.RelNode r,
> > >       org.apache.calcite.rel.metadata.RelMetadataQuery mq) {
> > >     if (r instanceof org.apache.calcite.plan.volcano.RelSubset) {
> > >       return
> > > provider0.getNodeTypes((org.apache.calcite.plan.volcano.RelSubset) r,
> > mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Aggregate) {
> > >       return
> > > provider0.getNodeTypes((org.apache.calcite.rel.core.Aggregate) r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Calc) {
> > >       return provider0.getNodeTypes((org.apache.calcite.rel.core.Calc)
> r,
> > > mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Correlate) {
> > >       return
> > > provider0.getNodeTypes((org.apache.calcite.rel.core.Correlate) r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Exchange) {
> > >       return
> > provider0.getNodeTypes((org.apache.calcite.rel.core.Exchange)
> > > r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Filter) {
> > >       return
> provider0.getNodeTypes((org.apache.calcite.rel.core.Filter)
> > > r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Intersect) {
> > >       return
> > > provider0.getNodeTypes((org.apache.calcite.rel.core.Intersect) r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Join) {
> > >       return provider0.getNodeTypes((org.apache.calcite.rel.core.Join)
> r,
> > > mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Match) {
> > >       return provider0.getNodeTypes((org.apache.calcite.rel.core.Match)
> > r,
> > > mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Minus) {
> > >       return provider0.getNodeTypes((org.apache.calcite.rel.core.Minus)
> > r,
> > > mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Project) {
> > >       return
> provider0.getNodeTypes((org.apache.calcite.rel.core.Project)
> > > r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Sample) {
> > >       return
> provider0.getNodeTypes((org.apache.calcite.rel.core.Sample)
> > > r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Sort) {
> > >       return provider0.getNodeTypes((org.apache.calcite.rel.core.Sort)
> r,
> > > mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.TableModify) {
> > >       return
> > > provider0.getNodeTypes((org.apache.calcite.rel.core.TableModify) r,
> mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.TableScan) {
> > >       return
> > > provider0.getNodeTypes((org.apache.calcite.rel.core.TableScan) r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Union) {
> > >       return provider0.getNodeTypes((org.apache.calcite.rel.core.Union)
> > r,
> > > mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Values) {
> > >       return
> provider0.getNodeTypes((org.apache.calcite.rel.core.Values)
> > > r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Window) {
> > >       return
> provider0.getNodeTypes((org.apache.calcite.rel.core.Window)
> > > r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.RelNode) {
> > >       return provider0.getNodeTypes((org.apache.calcite.rel.RelNode) r,
> > > mq);
> > >     } else {
> > >             throw new java.lang.IllegalArgumentException("No handler
> for
> > > method [public abstract com.google.common.collect.Multimap
> > >
> >
> org.apache.calcite.rel.metadata.BuiltInMetadata$NodeTypes$Handler.getNodeTypes(org.apache.calcite.rel.RelNode,org.apache.calcite.rel.metadata.RelMetadataQuery)]
> > > applied to argument of type [" + r.getClass() + "]; we recommend you
> > create
> > > a catch-all (RelNode) handler");
> > >     }
> > >   }
> > >
> > > }
> > >
> > > /*
> > >  * Licensed to the Apache Software Foundation (ASF) under one or more
> > >  * contributor license agreements.  See the NOTICE file distributed
> with
> > >  * this work for additional information regarding copyright ownership.
> > >  * The ASF licenses this file to you under the Apache License, Version
> > 2.0
> > >  * (the "License"); you may not use this file except in compliance with
> > >  * the License.  You may obtain a copy of the License at
> > >  *
> > >  * http://www.apache.org/licenses/LICENSE-2.0
> > >  *
> > >  * Unless required by applicable law or agreed to in writing, software
> > >  * distributed under the License is distributed on an "AS IS" BASIS,
> > >  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> > implied.
> > >  * See the License for the specific language governing permissions and
> > >  * limitations under the License.
> > >  */
> > > package org.apache.calcite.rel.metadata.janino;
> > >
> > > public final class GeneratedMetadata_PredicatesHandler
> > >   implements
> > > org.apache.calcite.rel.metadata.BuiltInMetadata.Predicates.Handler {
> > >   private final Object methodKey0 =
> > >       new
> > >
> >
> org.apache.calcite.rel.metadata.janino.DescriptiveCacheKey("RelOptPredicateList
> > > Handler.getPredicates()");
> > >   public final org.apache.calcite.rel.metadata.RelMdPredicates
> provider0;
> > >   public GeneratedMetadata_PredicatesHandler(
> > >       org.apache.calcite.rel.metadata.RelMdPredicates provider0) {
> > >     this.provider0 = provider0;
> > >   }
> > >   public org.apache.calcite.rel.metadata.MetadataDef getDef() {
> > >     return provider0.getDef();
> > >   }
> > >   public org.apache.calcite.plan.RelOptPredicateList getPredicates(
> > >       org.apache.calcite.rel.RelNode r,
> > >       org.apache.calcite.rel.metadata.RelMetadataQuery mq) {
> > >     while (r instanceof
> > > org.apache.calcite.rel.metadata.DelegatingMetadataRel) {
> > >       r = ((org.apache.calcite.rel.metadata.DelegatingMetadataRel)
> > > r).getMetadataDelegateRel();
> > >     }
> > >     final Object key;
> > >     key = methodKey0;
> > >     final Object v = mq.map.get(r, key);
> > >     if (v != null) {
> > >       if (v == org.apache.calcite.rel.metadata.NullSentinel.ACTIVE) {
> > >         throw new
> > > org.apache.calcite.rel.metadata.CyclicMetadataException();
> > >       }
> > >       if (v == org.apache.calcite.rel.metadata.NullSentinel.INSTANCE) {
> > >         return null;
> > >       }
> > >       return (org.apache.calcite.plan.RelOptPredicateList) v;
> > >     }
> > >     mq.map.put(r,
> > key,org.apache.calcite.rel.metadata.NullSentinel.ACTIVE);
> > >     try {
> > >       final org.apache.calcite.plan.RelOptPredicateList x =
> > > getPredicates_(r, mq);
> > >       mq.map.put(r, key,
> > > org.apache.calcite.rel.metadata.NullSentinel.mask(x));
> > >       return x;
> > >     } catch (java.lang.Exception e) {
> > >       mq.map.row(r).clear();
> > >       throw e;
> > >     }
> > >   }
> > >
> > >   private org.apache.calcite.plan.RelOptPredicateList getPredicates_(
> > >       org.apache.calcite.rel.RelNode r,
> > >       org.apache.calcite.rel.metadata.RelMetadataQuery mq) {
> > >     if (r instanceof org.apache.calcite.plan.volcano.RelSubset) {
> > >       return
> > > provider0.getPredicates((org.apache.calcite.plan.volcano.RelSubset) r,
> > mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Aggregate) {
> > >       return
> > > provider0.getPredicates((org.apache.calcite.rel.core.Aggregate) r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Exchange) {
> > >       return
> > > provider0.getPredicates((org.apache.calcite.rel.core.Exchange) r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Filter) {
> > >       return
> provider0.getPredicates((org.apache.calcite.rel.core.Filter)
> > > r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Intersect) {
> > >       return
> > > provider0.getPredicates((org.apache.calcite.rel.core.Intersect) r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Join) {
> > >       return provider0.getPredicates((org.apache.calcite.rel.core.Join)
> > r,
> > > mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Minus) {
> > >       return
> provider0.getPredicates((org.apache.calcite.rel.core.Minus)
> > > r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Project) {
> > >       return
> > provider0.getPredicates((org.apache.calcite.rel.core.Project)
> > > r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Sort) {
> > >       return provider0.getPredicates((org.apache.calcite.rel.core.Sort)
> > r,
> > > mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.TableModify) {
> > >       return
> > > provider0.getPredicates((org.apache.calcite.rel.core.TableModify) r,
> mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.TableScan) {
> > >       return
> > > provider0.getPredicates((org.apache.calcite.rel.core.TableScan) r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Union) {
> > >       return
> provider0.getPredicates((org.apache.calcite.rel.core.Union)
> > > r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.RelNode) {
> > >       return provider0.getPredicates((org.apache.calcite.rel.RelNode)
> r,
> > > mq);
> > >     } else {
> > >             throw new java.lang.IllegalArgumentException("No handler
> for
> > > method [public abstract org.apache.calcite.plan.RelOptPredicateList
> > >
> >
> org.apache.calcite.rel.metadata.BuiltInMetadata$Predicates$Handler.getPredicates(org.apache.calcite.rel.RelNode,org.apache.calcite.rel.metadata.RelMetadataQuery)]
> > > applied to argument of type [" + r.getClass() + "]; we recommend you
> > create
> > > a catch-all (RelNode) handler");
> > >     }
> > >   }
> > >
> > > }
> > >
> > > /*
> > >  * Licensed to the Apache Software Foundation (ASF) under one or more
> > >  * contributor license agreements.  See the NOTICE file distributed
> with
> > >  * this work for additional information regarding copyright ownership.
> > >  * The ASF licenses this file to you under the Apache License, Version
> > 2.0
> > >  * (the "License"); you may not use this file except in compliance with
> > >  * the License.  You may obtain a copy of the License at
> > >  *
> > >  * http://www.apache.org/licenses/LICENSE-2.0
> > >  *
> > >  * Unless required by applicable law or agreed to in writing, software
> > >  * distributed under the License is distributed on an "AS IS" BASIS,
> > >  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> > implied.
> > >  * See the License for the specific language governing permissions and
> > >  * limitations under the License.
> > >  */
> > > package org.apache.calcite.rel.metadata.janino;
> > >
> > > public final class GeneratedMetadata_RowCountHandler
> > >   implements
> > > org.apache.calcite.rel.metadata.BuiltInMetadata.RowCount.Handler {
> > >   private final Object methodKey0 =
> > >       new
> > > org.apache.calcite.rel.metadata.janino.DescriptiveCacheKey("Double
> > > Handler.getRowCount()");
> > >   public final org.apache.calcite.rel.metadata.RelMdRowCount provider0;
> > >   public GeneratedMetadata_RowCountHandler(
> > >       org.apache.calcite.rel.metadata.RelMdRowCount provider0) {
> > >     this.provider0 = provider0;
> > >   }
> > >   public org.apache.calcite.rel.metadata.MetadataDef getDef() {
> > >     return provider0.getDef();
> > >   }
> > >   public java.lang.Double getRowCount(
> > >       org.apache.calcite.rel.RelNode r,
> > >       org.apache.calcite.rel.metadata.RelMetadataQuery mq) {
> > >     while (r instanceof
> > > org.apache.calcite.rel.metadata.DelegatingMetadataRel) {
> > >       r = ((org.apache.calcite.rel.metadata.DelegatingMetadataRel)
> > > r).getMetadataDelegateRel();
> > >     }
> > >     final Object key;
> > >     key = methodKey0;
> > >     final Object v = mq.map.get(r, key);
> > >     if (v != null) {
> > >       if (v == org.apache.calcite.rel.metadata.NullSentinel.ACTIVE) {
> > >         throw new
> > > org.apache.calcite.rel.metadata.CyclicMetadataException();
> > >       }
> > >       if (v == org.apache.calcite.rel.metadata.NullSentinel.INSTANCE) {
> > >         return null;
> > >       }
> > >       return (java.lang.Double) v;
> > >     }
> > >     mq.map.put(r,
> > key,org.apache.calcite.rel.metadata.NullSentinel.ACTIVE);
> > >     try {
> > >       final java.lang.Double x = getRowCount_(r, mq);
> > >       mq.map.put(r, key,
> > > org.apache.calcite.rel.metadata.NullSentinel.mask(x));
> > >       return x;
> > >     } catch (java.lang.Exception e) {
> > >       mq.map.row(r).clear();
> > >       throw e;
> > >     }
> > >   }
> > >
> > >   private java.lang.Double getRowCount_(
> > >       org.apache.calcite.rel.RelNode r,
> > >       org.apache.calcite.rel.metadata.RelMetadataQuery mq) {
> > >     if (r instanceof
> > > org.apache.calcite.adapter.enumerable.EnumerableLimit) {
> > >       return
> > >
> >
> provider0.getRowCount((org.apache.calcite.adapter.enumerable.EnumerableLimit)
> > > r, mq);
> > >     } else if (r instanceof org.apache.calcite.plan.volcano.RelSubset)
> {
> > >       return
> > > provider0.getRowCount((org.apache.calcite.plan.volcano.RelSubset) r,
> mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Aggregate) {
> > >       return
> > provider0.getRowCount((org.apache.calcite.rel.core.Aggregate)
> > > r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Calc) {
> > >       return provider0.getRowCount((org.apache.calcite.rel.core.Calc)
> r,
> > > mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Exchange) {
> > >       return
> provider0.getRowCount((org.apache.calcite.rel.core.Exchange)
> > > r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Filter) {
> > >       return provider0.getRowCount((org.apache.calcite.rel.core.Filter)
> > r,
> > > mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Intersect) {
> > >       return
> > provider0.getRowCount((org.apache.calcite.rel.core.Intersect)
> > > r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Join) {
> > >       return provider0.getRowCount((org.apache.calcite.rel.core.Join)
> r,
> > > mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Minus) {
> > >       return provider0.getRowCount((org.apache.calcite.rel.core.Minus)
> r,
> > > mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Project) {
> > >       return
> provider0.getRowCount((org.apache.calcite.rel.core.Project)
> > > r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Sort) {
> > >       return provider0.getRowCount((org.apache.calcite.rel.core.Sort)
> r,
> > > mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.TableModify) {
> > >       return
> > > provider0.getRowCount((org.apache.calcite.rel.core.TableModify) r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.TableScan) {
> > >       return
> > provider0.getRowCount((org.apache.calcite.rel.core.TableScan)
> > > r, mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Union) {
> > >       return provider0.getRowCount((org.apache.calcite.rel.core.Union)
> r,
> > > mq);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Values) {
> > >       return provider0.getRowCount((org.apache.calcite.rel.core.Values)
> > r,
> > > mq);
> > >     } else if (r instanceof org.apache.calcite.rel.SingleRel) {
> > >       return provider0.getRowCount((org.apache.calcite.rel.SingleRel)
> r,
> > > mq);
> > >     } else if (r instanceof org.apache.calcite.rel.RelNode) {
> > >       return provider0.getRowCount((org.apache.calcite.rel.RelNode) r,
> > mq);
> > >     } else {
> > >             throw new java.lang.IllegalArgumentException("No handler
> for
> > > method [public abstract java.lang.Double
> > >
> >
> org.apache.calcite.rel.metadata.BuiltInMetadata$RowCount$Handler.getRowCount(org.apache.calcite.rel.RelNode,org.apache.calcite.rel.metadata.RelMetadataQuery)]
> > > applied to argument of type [" + r.getClass() + "]; we recommend you
> > create
> > > a catch-all (RelNode) handler");
> > >     }
> > >   }
> > >
> > > }
> > >
> > > /*
> > >  * Licensed to the Apache Software Foundation (ASF) under one or more
> > >  * contributor license agreements.  See the NOTICE file distributed
> with
> > >  * this work for additional information regarding copyright ownership.
> > >  * The ASF licenses this file to you under the Apache License, Version
> > 2.0
> > >  * (the "License"); you may not use this file except in compliance with
> > >  * the License.  You may obtain a copy of the License at
> > >  *
> > >  * http://www.apache.org/licenses/LICENSE-2.0
> > >  *
> > >  * Unless required by applicable law or agreed to in writing, software
> > >  * distributed under the License is distributed on an "AS IS" BASIS,
> > >  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> > implied.
> > >  * See the License for the specific language governing permissions and
> > >  * limitations under the License.
> > >  */
> > > package org.apache.calcite.rel.metadata.janino;
> > >
> > > public final class GeneratedMetadata_DistinctRowCountHandler
> > >   implements
> > >
> org.apache.calcite.rel.metadata.BuiltInMetadata.DistinctRowCount.Handler
> > {
> > >   private final Object methodKey0 =
> > >       new
> > > org.apache.calcite.rel.metadata.janino.DescriptiveCacheKey("Double
> > > Handler.getDistinctRowCount(RelNode, RelMetadataQuery, ImmutableBitSet,
> > > RexNode)");
> > >   public final org.apache.calcite.rel.metadata.RelMdDistinctRowCount
> > > provider0;
> > >   public GeneratedMetadata_DistinctRowCountHandler(
> > >       org.apache.calcite.rel.metadata.RelMdDistinctRowCount provider0)
> {
> > >     this.provider0 = provider0;
> > >   }
> > >   public org.apache.calcite.rel.metadata.MetadataDef getDef() {
> > >     return provider0.getDef();
> > >   }
> > >   public java.lang.Double getDistinctRowCount(
> > >       org.apache.calcite.rel.RelNode r,
> > >       org.apache.calcite.rel.metadata.RelMetadataQuery mq,
> > >       org.apache.calcite.util.ImmutableBitSet a2,
> > >       org.apache.calcite.rex.RexNode a3) {
> > >     while (r instanceof
> > > org.apache.calcite.rel.metadata.DelegatingMetadataRel) {
> > >       r = ((org.apache.calcite.rel.metadata.DelegatingMetadataRel)
> > > r).getMetadataDelegateRel();
> > >     }
> > >     final Object key;
> > >     key = org.apache.calcite.runtime.FlatLists.of(methodKey0,
> > > org.apache.calcite.rel.metadata.NullSentinel.mask(a2), a3);
> > >     final Object v = mq.map.get(r, key);
> > >     if (v != null) {
> > >       if (v == org.apache.calcite.rel.metadata.NullSentinel.ACTIVE) {
> > >         throw new
> > > org.apache.calcite.rel.metadata.CyclicMetadataException();
> > >       }
> > >       if (v == org.apache.calcite.rel.metadata.NullSentinel.INSTANCE) {
> > >         return null;
> > >       }
> > >       return (java.lang.Double) v;
> > >     }
> > >     mq.map.put(r,
> > key,org.apache.calcite.rel.metadata.NullSentinel.ACTIVE);
> > >     try {
> > >       final java.lang.Double x = getDistinctRowCount_(r, mq, a2, a3);
> > >       mq.map.put(r, key,
> > > org.apache.calcite.rel.metadata.NullSentinel.mask(x));
> > >       return x;
> > >     } catch (java.lang.Exception e) {
> > >       mq.map.row(r).clear();
> > >       throw e;
> > >     }
> > >   }
> > >
> > >   private java.lang.Double getDistinctRowCount_(
> > >       org.apache.calcite.rel.RelNode r,
> > >       org.apache.calcite.rel.metadata.RelMetadataQuery mq,
> > >       org.apache.calcite.util.ImmutableBitSet a2,
> > >       org.apache.calcite.rex.RexNode a3) {
> > >     if (r instanceof org.apache.calcite.plan.volcano.RelSubset) {
> > >       return
> > >
> provider0.getDistinctRowCount((org.apache.calcite.plan.volcano.RelSubset)
> > > r, mq, a2, a3);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Aggregate) {
> > >       return
> > > provider0.getDistinctRowCount((org.apache.calcite.rel.core.Aggregate)
> r,
> > > mq, a2, a3);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Exchange) {
> > >       return
> > > provider0.getDistinctRowCount((org.apache.calcite.rel.core.Exchange) r,
> > mq,
> > > a2, a3);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Filter) {
> > >       return
> > > provider0.getDistinctRowCount((org.apache.calcite.rel.core.Filter) r,
> mq,
> > > a2, a3);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Join) {
> > >       return
> > > provider0.getDistinctRowCount((org.apache.calcite.rel.core.Join) r, mq,
> > a2,
> > > a3);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Project) {
> > >       return
> > > provider0.getDistinctRowCount((org.apache.calcite.rel.core.Project) r,
> > mq,
> > > a2, a3);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Sort) {
> > >       return
> > > provider0.getDistinctRowCount((org.apache.calcite.rel.core.Sort) r, mq,
> > a2,
> > > a3);
> > >     } else if (r instanceof org.apache.calcite.rel.core.TableModify) {
> > >       return
> > > provider0.getDistinctRowCount((org.apache.calcite.rel.core.TableModify)
> > r,
> > > mq, a2, a3);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Union) {
> > >       return
> > > provider0.getDistinctRowCount((org.apache.calcite.rel.core.Union) r,
> mq,
> > > a2, a3);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Values) {
> > >       return
> > > provider0.getDistinctRowCount((org.apache.calcite.rel.core.Values) r,
> mq,
> > > a2, a3);
> > >     } else if (r instanceof org.apache.calcite.rel.RelNode) {
> > >       return
> > > provider0.getDistinctRowCount((org.apache.calcite.rel.RelNode) r, mq,
> a2,
> > > a3);
> > >     } else {
> > >             throw new java.lang.IllegalArgumentException("No handler
> for
> > > method [public abstract java.lang.Double
> > >
> >
> org.apache.calcite.rel.metadata.BuiltInMetadata$DistinctRowCount$Handler.getDistinctRowCount(org.apache.calcite.rel.RelNode,org.apache.calcite.rel.metadata.RelMetadataQuery,org.apache.calcite.util.ImmutableBitSet,org.apache.calcite.rex.RexNode)]
> > > applied to argument of type [" + r.getClass() + "]; we recommend you
> > create
> > > a catch-all (RelNode) handler");
> > >     }
> > >   }
> > >
> > > }
> > >
> > > /*
> > >  * Licensed to the Apache Software Foundation (ASF) under one or more
> > >  * contributor license agreements.  See the NOTICE file distributed
> with
> > >  * this work for additional information regarding copyright ownership.
> > >  * The ASF licenses this file to you under the Apache License, Version
> > 2.0
> > >  * (the "License"); you may not use this file except in compliance with
> > >  * the License.  You may obtain a copy of the License at
> > >  *
> > >  * http://www.apache.org/licenses/LICENSE-2.0
> > >  *
> > >  * Unless required by applicable law or agreed to in writing, software
> > >  * distributed under the License is distributed on an "AS IS" BASIS,
> > >  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> > implied.
> > >  * See the License for the specific language governing permissions and
> > >  * limitations under the License.
> > >  */
> > > package org.apache.calcite.rel.metadata.janino;
> > >
> > > public final class GeneratedMetadata_ColumnUniquenessHandler
> > >   implements
> > >
> org.apache.calcite.rel.metadata.BuiltInMetadata.ColumnUniqueness.Handler
> > {
> > >   private final Object methodKey0 =
> > >       new
> > > org.apache.calcite.rel.metadata.janino.DescriptiveCacheKey("Boolean
> > > Handler.areColumnsUnique(RelNode, RelMetadataQuery, ImmutableBitSet,
> > > boolean)");
> > >   public final org.apache.calcite.rel.metadata.RelMdColumnUniqueness
> > > provider0;
> > >   public GeneratedMetadata_ColumnUniquenessHandler(
> > >       org.apache.calcite.rel.metadata.RelMdColumnUniqueness provider0)
> {
> > >     this.provider0 = provider0;
> > >   }
> > >   public org.apache.calcite.rel.metadata.MetadataDef getDef() {
> > >     return provider0.getDef();
> > >   }
> > >   public java.lang.Boolean areColumnsUnique(
> > >       org.apache.calcite.rel.RelNode r,
> > >       org.apache.calcite.rel.metadata.RelMetadataQuery mq,
> > >       org.apache.calcite.util.ImmutableBitSet a2,
> > >       boolean a3) {
> > >     while (r instanceof
> > > org.apache.calcite.rel.metadata.DelegatingMetadataRel) {
> > >       r = ((org.apache.calcite.rel.metadata.DelegatingMetadataRel)
> > > r).getMetadataDelegateRel();
> > >     }
> > >     final Object key;
> > >     key = org.apache.calcite.runtime.FlatLists.of(methodKey0,
> > > org.apache.calcite.rel.metadata.NullSentinel.mask(a2), a3);
> > >     final Object v = mq.map.get(r, key);
> > >     if (v != null) {
> > >       if (v == org.apache.calcite.rel.metadata.NullSentinel.ACTIVE) {
> > >         throw new
> > > org.apache.calcite.rel.metadata.CyclicMetadataException();
> > >       }
> > >       if (v == org.apache.calcite.rel.metadata.NullSentinel.INSTANCE) {
> > >         return null;
> > >       }
> > >       return (java.lang.Boolean) v;
> > >     }
> > >     mq.map.put(r,
> > key,org.apache.calcite.rel.metadata.NullSentinel.ACTIVE);
> > >     try {
> > >       final java.lang.Boolean x = areColumnsUnique_(r, mq, a2, a3);
> > >       mq.map.put(r, key,
> > > org.apache.calcite.rel.metadata.NullSentinel.mask(x));
> > >       return x;
> > >     } catch (java.lang.Exception e) {
> > >       mq.map.row(r).clear();
> > >       throw e;
> > >     }
> > >   }
> > >
> > >   private java.lang.Boolean areColumnsUnique_(
> > >       org.apache.calcite.rel.RelNode r,
> > >       org.apache.calcite.rel.metadata.RelMetadataQuery mq,
> > >       org.apache.calcite.util.ImmutableBitSet a2,
> > >       boolean a3) {
> > >     if (r instanceof org.apache.calcite.plan.volcano.RelSubset) {
> > >       return
> > > provider0.areColumnsUnique((org.apache.calcite.plan.volcano.RelSubset)
> r,
> > > mq, a2, a3);
> > >     } else if (r instanceof org.apache.calcite.rel.convert.Converter) {
> > >       return
> > > provider0.areColumnsUnique((org.apache.calcite.rel.convert.Converter)
> r,
> > > mq, a2, a3);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Aggregate) {
> > >       return
> > > provider0.areColumnsUnique((org.apache.calcite.rel.core.Aggregate) r,
> mq,
> > > a2, a3);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Calc) {
> > >       return
> > provider0.areColumnsUnique((org.apache.calcite.rel.core.Calc)
> > > r, mq, a2, a3);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Correlate) {
> > >       return
> > > provider0.areColumnsUnique((org.apache.calcite.rel.core.Correlate) r,
> mq,
> > > a2, a3);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Exchange) {
> > >       return
> > > provider0.areColumnsUnique((org.apache.calcite.rel.core.Exchange) r,
> mq,
> > > a2, a3);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Filter) {
> > >       return
> > > provider0.areColumnsUnique((org.apache.calcite.rel.core.Filter) r, mq,
> > a2,
> > > a3);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Intersect) {
> > >       return
> > > provider0.areColumnsUnique((org.apache.calcite.rel.core.Intersect) r,
> mq,
> > > a2, a3);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Join) {
> > >       return
> > provider0.areColumnsUnique((org.apache.calcite.rel.core.Join)
> > > r, mq, a2, a3);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Minus) {
> > >       return
> > > provider0.areColumnsUnique((org.apache.calcite.rel.core.Minus) r, mq,
> a2,
> > > a3);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Project) {
> > >       return
> > > provider0.areColumnsUnique((org.apache.calcite.rel.core.Project) r, mq,
> > a2,
> > > a3);
> > >     } else if (r instanceof org.apache.calcite.rel.core.SetOp) {
> > >       return
> > > provider0.areColumnsUnique((org.apache.calcite.rel.core.SetOp) r, mq,
> a2,
> > > a3);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Sort) {
> > >       return
> > provider0.areColumnsUnique((org.apache.calcite.rel.core.Sort)
> > > r, mq, a2, a3);
> > >     } else if (r instanceof org.apache.calcite.rel.core.TableModify) {
> > >       return
> > > provider0.areColumnsUnique((org.apache.calcite.rel.core.TableModify) r,
> > mq,
> > > a2, a3);
> > >     } else if (r instanceof org.apache.calcite.rel.core.TableScan) {
> > >       return
> > > provider0.areColumnsUnique((org.apache.calcite.rel.core.TableScan) r,
> mq,
> > > a2, a3);
> > >     } else if (r instanceof org.apache.calcite.rel.core.Values) {
> > >       return
> > > provider0.areColumnsUnique((org.apache.calcite.rel.core.Values) r, mq,
> > a2,
> > > a3);
> > >     } else if (r instanceof org.apache.calcite.rel.RelNode) {
> > >       return
> provider0.areColumnsUnique((org.apache.calcite.rel.RelNode)
> > > r, mq, a2, a3);
> > >     } else {
> > >             throw new java.lang.IllegalArgumentException("No handler
> for
> > > method [public abstract java.lang.Boolean
> > >
> >
> org.apache.calcite.rel.metadata.BuiltInMetadata$ColumnUniqueness$Handler.areColumnsUnique(org.apache.calcite.rel.RelNode,org.apache.calcite.rel.metadata.RelMetadataQuery,org.apache.calcite.util.ImmutableBitSet,boolean)]
> > > applied to argument of type [" + r.getClass() + "]; we recommend you
> > create
> > > a catch-all (RelNode) handler");
> > >     }
> > >   }
> > >
> > > }
> > >
> > >
> > > /*   1 */ public static class Record1_0 implements
> java.io.Serializable {
> > > /*   2 */   public long f0;
> > > /*   3 */   public Record1_0() {}
> > > /*   4 */   public boolean equals(Object o) {
> > > /*   5 */     if (this == o) {
> > > /*   6 */       return true;
> > > /*   7 */     }
> > > /*   8 */     if (!(o instanceof Record1_0)) {
> > > /*   9 */       return false;
> > > /*  10 */     }
> > > /*  11 */     return this.f0 == ((Record1_0) o).f0;
> > > /*  12 */   }
> > > /*  13 */
> > > /*  14 */   public int hashCode() {
> > > /*  15 */     int h = 0;
> > > /*  16 */     h = org.apache.calcite.runtime.Utilities.hash(h,
> this.f0);
> > > /*  17 */     return h;
> > > /*  18 */   }
> > > /*  19 */
> > > /*  20 */   public int compareTo(Record1_0 that) {
> > > /*  21 */     final int c;
> > > /*  22 */     c = org.apache.calcite.runtime.Utilities.compare(this.f0,
> > > that.f0);
> > > /*  23 */     if (c != 0) {
> > > /*  24 */       return c;
> > > /*  25 */     }
> > > /*  26 */     return 0;
> > > /*  27 */   }
> > > /*  28 */
> > > /*  29 */   public String toString() {
> > > /*  30 */     return "{f0=" + this.f0 + "}";
> > > /*  31 */   }
> > > /*  32 */
> > > /*  33 */ }
> > > /*  34 */
> > > /*  35 */ public org.apache.calcite.linq4j.Enumerable bind(final
> > > org.apache.calcite.DataContext root) {
> > > /*  36 */   java.util.List accumulatorAdders = new
> > java.util.LinkedList();
> > > /*  37 */   accumulatorAdders.add(new
> > > org.apache.calcite.linq4j.function.Function2() {
> > > /*  38 */     public Record1_0 apply(Record1_0 acc, Object[] in) {
> > > /*  39 */       acc.f0++;
> > > /*  40 */       return acc;
> > > /*  41 */     }
> > > /*  42 */     public Record1_0 apply(Object acc, Object in) {
> > > /*  43 */       return apply(
> > > /*  44 */         (Record1_0) acc,
> > > /*  45 */         (Object[]) in);
> > > /*  46 */     }
> > > /*  47 */   }
> > > /*  48 */   );
> > > /*  49 */
>  org.apache.calcite.adapter.enumerable.AggregateLambdaFactory
> > > lambdaFactory = new
> > > org.apache.calcite.adapter.enumerable.BasicAggregateLambdaFactory(
> > > /*  50 */     new org.apache.calcite.linq4j.function.Function0() {
> > > /*  51 */       public Object apply() {
> > > /*  52 */         long COUNTa0s0;
> > > /*  53 */         COUNTa0s0 = 0L;
> > > /*  54 */         Record1_0 record0;
> > > /*  55 */         record0 = new Record1_0();
> > > /*  56 */         record0.f0 = COUNTa0s0;
> > > /*  57 */         return record0;
> > > /*  58 */       }
> > > /*  59 */     }
> > > /*  60 */ ,
> > > /*  61 */     accumulatorAdders);
> > > /*  62 */   return
> > >
> >
> org.apache.calcite.linq4j.Linq4j.singletonEnumerable(org.apache.calcite.schema.Schemas.enumerable((org.apache.calcite.schema.ScannableTable)
> > > root.getRootSchema().getSubSchema("js").getTable("t1"),
> > > root).aggregate(lambdaFactory.accumulatorInitializer().apply(),
> > > lambdaFactory.accumulatorAdder(),
> > > lambdaFactory.singleGroupResultSelector(new
> > > org.apache.calcite.linq4j.function.Function1() {
> > > /*  63 */       public long apply(Record1_0 acc) {
> > > /*  64 */         return acc.f0;
> > > /*  65 */       }
> > > /*  66 */       public Object apply(Object acc) {
> > > /*  67 */         return apply(
> > > /*  68 */           (Record1_0) acc);
> > > /*  69 */       }
> > > /*  70 */     }
> > > /*  71 */     )));
> > > /*  72 */ }
> > > /*  73 */
> > > /*  74 */
> > > /*  75 */ public Class getElementType() {
> > > /*  76 */   return long.class;
> > > /*  77 */ }
> > > /*  78 */
> > > /*  79 */
> > > 2022-02-23 15:02:59.636  INFO 78585 --- [           main]
> > > ConditionEvaluationReportLoggingListener :
> > >
> > > Error starting ApplicationContext. To display the conditions report
> > re-run
> > > your application with 'debug' enabled.
> > > 2022-02-23 15:02:59.703 ERROR 78585 --- [           main]
> > > o.s.boot.SpringApplication               : Application run failed
> > >
> > > java.lang.IllegalStateException: Failed to execute ApplicationRunner
> > >         at
> > >
> >
> org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:761)
> > > ~[spring-boot-2.6.2.jar:2.6.2]
> > >         at
> > >
> >
> org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:748)
> > > ~[spring-boot-2.6.2.jar:2.6.2]
> > >         at
> > >
> >
> org.springframework.boot.SpringApplication.run(SpringApplication.java:309)
> > > ~[spring-boot-2.6.2.jar:2.6.2]
> > >         at
> > >
> >
> org.springframework.boot.SpringApplication.run(SpringApplication.java:1301)
> > > ~[spring-boot-2.6.2.jar:2.6.2]
> > >         at
> > >
> >
> org.springframework.boot.SpringApplication.run(SpringApplication.java:1290)
> > > ~[spring-boot-2.6.2.jar:2.6.2]
> > >         at
> > >
> >
> com.xsmartware.javatest.JavaTestApplication.main(JavaTestApplication.java:9)
> > > ~[classes/:na]
> > > Caused by: java.sql.SQLException: Error while executing SQL "select
> > > count(*) from js.t1": null
> > >         at
> > > org.apache.calcite.avatica.Helper.createException(Helper.java:56)
> > > ~[avatica-core-1.20.0.jar:1.20.0]
> > >         at
> > > org.apache.calcite.avatica.Helper.createException(Helper.java:41)
> > > ~[avatica-core-1.20.0.jar:1.20.0]
> > >         at
> > >
> >
> org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:163)
> > > ~[avatica-core-1.20.0.jar:1.20.0]
> > >         at
> > >
> >
> org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:227)
> > > ~[avatica-core-1.20.0.jar:1.20.0]
> > >         at
> com.xsmartware.common.util.SQLUtil.exeGetLong(SQLUtil.java:42)
> > > ~[classes/:na]
> > >         at
> > >
> com.xsmartware.javatest.calcite.CalCiteTest.test10(CalCiteTest.java:145)
> > > ~[classes/:na]
> > >         at
> > > com.xsmartware.javatest.calcite.CalCiteTest.run(CalCiteTest.java:114)
> > > ~[classes/:na]
> > >         at
> > >
> >
> org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:758)
> > > ~[spring-boot-2.6.2.jar:2.6.2]
> > >         ... 5 common frames omitted
> > > Caused by: java.lang.NullPointerException: null
> > >         at
> > >
> >
> org.apache.calcite.adapter.json.JsonEnumerator.<init>(JsonEnumerator.java:49)
> > > ~[classes/:na]
> > >         at
> > >
> >
> org.apache.calcite.adapter.json.JsonScannableTable$1.enumerator(JsonScannableTable.java:48)
> > > ~[classes/:na]
> > >         at
> > >
> >
> org.apache.calcite.linq4j.EnumerableDefaults.aggregate(EnumerableDefaults.java:130)
> > > ~[calcite-linq4j-1.29.0.jar:1.29.0]
> > >         at
> > >
> >
> org.apache.calcite.linq4j.DefaultEnumerable.aggregate(DefaultEnumerable.java:107)
> > > ~[calcite-linq4j-1.29.0.jar:1.29.0]
> > >         at Baz.bind(Baz.java:62) ~[na:na]
> > >         at
> > >
> >
> org.apache.calcite.jdbc.CalcitePrepare$CalciteSignature.enumerable(CalcitePrepare.java:363)
> > > ~[calcite-core-1.29.0.jar:1.29.0]
> > >         at
> > >
> >
> org.apache.calcite.jdbc.CalciteConnectionImpl.enumerable(CalciteConnectionImpl.java:338)
> > > ~[calcite-core-1.29.0.jar:1.29.0]
> > >         at
> > >
> >
> org.apache.calcite.jdbc.CalciteMetaImpl._createIterable(CalciteMetaImpl.java:578)
> > > ~[calcite-core-1.29.0.jar:1.29.0]
> > >         at
> > >
> >
> org.apache.calcite.jdbc.CalciteMetaImpl.createIterable(CalciteMetaImpl.java:569)
> > > ~[calcite-core-1.29.0.jar:1.29.0]
> > >         at
> > >
> >
> org.apache.calcite.avatica.AvaticaResultSet.execute(AvaticaResultSet.java:184)
> > > ~[avatica-core-1.20.0.jar:1.20.0]
> > >         at
> > >
> >
> org.apache.calcite.jdbc.CalciteResultSet.execute(CalciteResultSet.java:64)
> > > ~[calcite-core-1.29.0.jar:1.29.0]
> > >         at
> > >
> >
> org.apache.calcite.jdbc.CalciteResultSet.execute(CalciteResultSet.java:43)
> > > ~[calcite-core-1.29.0.jar:1.29.0]
> > >         at
> > >
> >
> org.apache.calcite.avatica.AvaticaConnection$1.execute(AvaticaConnection.java:666)
> > > ~[avatica-core-1.20.0.jar:1.20.0]
> > >         at
> > >
> >
> org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:638)
> > > ~[calcite-core-1.29.0.jar:1.29.0]
> > >         at
> > >
> >
> org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:674)
> > > ~[avatica-core-1.20.0.jar:1.20.0]
> > >         at
> > >
> >
> org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:156)
> > > ~[avatica-core-1.20.0.jar:1.20.0]
> > >         ... 10 common frames omitted
> > >
> > >
> > >
> > >
> > >
> > > ------------------ Original ------------------
> > > From:  "Julian Hyde";<jhyde.apa...@gmail.com>;
> > > Send time: Wednesday, Feb 23, 2022 8:27 AM
> > > To: "dev"<dev@calcite.apache.org>;
> > >
> > > Subject:  Re: dynamic reflective schema
> > >
> > >
> > >
> > > Every time I see "at Baz.bind” I am reminded that I should have chosen
> a
> > > better name for that class than ‘Baz’. :)
> > >
> > > I figured ‘it’s generated, no one is ever going to know its name’. How
> > > wrong I was. The stack traces are all over the internet.
> > >
> > > Julian
> > >
> > >
> > > > On Feb 22, 2022, at 3:32 PM, Scott Reynolds <sdrreyno...@gmail.com>
> > > wrote:
> > > >
> > > > Whenever I see "at Baz.bind(Unknown Source)" I am reminded how
> > important
> > > it
> > > > is, when debugging, to set the System Property calcite.debug = true
> > > >
> > >
> >
> https://github.com/apache/calcite/blob/a8a6569e6ba75efe9d5725c49338a7f181d3ab5c/core/src/main/java/org/apache/calcite/config/CalciteSystemProperty.java#L59
> > > >
> > > > That will get you a good stack trace and will help you figure out the
> > > > generated code is attempting to do.
> > > >
> > > > On Tue, Feb 22, 2022 at 5:35 AM xiaobo <guxiaobo1...@qq.com.invalid>
> > > wrote:
> > > >
> > > >> we have static data conbination use cases , reflective shcema&nbsp;
> is
> > > the
> > > >> best choice!
> > > >>
> > > >>
> > > >>
> > > >> ---Original---
> > > >> From: "Gavin Ray"<ray.gavi...@gmail.com&gt;
> > > >> Date: Mon, Feb 21, 2022 01:52 AM
> > > >> To: "dev"<dev@calcite.apache.org&gt;;
> > > >> Subject: Re: dynamic reflective schema
> > > >>
> > > >>
> > > >> Ah, you don't want to use ReflectiveSchema, it's a simple schema
> type
> > > meant
> > > >> for easily making test schemas
> > > >>
> > > >> You want to extend from "AbstractSchema" and override the function
> > > >> "Map<String, Table&gt; getTableMap()"
> > > >> For the "Table" type, you probably want to use "JsonScannableTable"
> > > >>
> > > >> The CsvSchema example does exactly this, if you want to see an
> example
> > > >> implementation:
> > > >>
> > > >>
> > >
> >
> https://github.com/apache/calcite/blob/4bc916619fd286b2c0cc4d5c653c96a68801d74e/example/csv/src/main/java/org/apache/calcite/adapter/csv/CsvSchema.java#L69-L106
> > > >>
> > > >> Hope this helps =)
> > > >>
> > > >>
> > > >>
> > > >> On Sat, Feb 19, 2022 at 11:03 PM xiaobo <guxiaobo1...@qq.com.invalid
> > > &gt;
> > > >> wrote:
> > > >>
> > > >> &gt; Hi,
> > > >> &gt; When using&nbsp; reflectiveSchema we must define a static Java
> > > class
> > > >> for the
> > > >> &gt; schema object, but in our use case the actual data to query is
> > > >> dynamic,
> > > >> &gt; define JAVA class for each data combination is impossible, we
> > have
> > > an
> > > >> idea
> > > >> &gt; that can we make a JSONSchema which accepts a Map<String,
> > > >> &gt; List<JSONObject&gt;&gt;, so that each List will be mapped to a
> > > table
> > > >> , and each
> > > >> &gt; JSONObject mapped to a row, JSONObject keys will be column
> names.
> > > Is
> > > >> there
> > > >> &gt; anything similar with this?
> > > >> &gt;
> > > >> &gt;
> > > >> &gt; Regards
>

Reply via email to