normanj-bitquill commented on code in PR #3826:
URL: https://github.com/apache/calcite/pull/3826#discussion_r1664546778


##########
core/src/test/java/org/apache/calcite/test/LargeGeneratedJoinTest.java:
##########
@@ -0,0 +1,156 @@
+/*
+ * 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.test;
+
+import org.apache.calcite.adapter.enumerable.EnumerableRules;
+import org.apache.calcite.adapter.java.AbstractQueryableTable;
+import org.apache.calcite.config.CalciteConnectionProperty;
+import org.apache.calcite.config.Lex;
+import org.apache.calcite.interpreter.Row;
+import org.apache.calcite.jdbc.CalciteSchema;
+import org.apache.calcite.linq4j.Enumerable;
+import org.apache.calcite.linq4j.Linq4j;
+import org.apache.calcite.linq4j.QueryProvider;
+import org.apache.calcite.linq4j.Queryable;
+import org.apache.calcite.plan.RelOptPlanner;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeFactory;
+import org.apache.calcite.runtime.Hook;
+import org.apache.calcite.schema.QueryableTable;
+import org.apache.calcite.schema.Schema;
+import org.apache.calcite.schema.SchemaPlus;
+import org.apache.calcite.schema.Table;
+import org.apache.calcite.schema.impl.AbstractSchema;
+import org.apache.calcite.sql.parser.SqlParseException;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.calcite.tools.RelConversionException;
+import org.apache.calcite.tools.ValidationException;
+
+import com.google.common.collect.ImmutableMap;
+
+import org.junit.jupiter.api.Test;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Function;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Test class for CALCITE-3094.

Review Comment:
   Updated.



##########
core/src/test/java/org/apache/calcite/test/LargeGeneratedJoinTest.java:
##########
@@ -0,0 +1,156 @@
+/*
+ * 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.test;
+
+import org.apache.calcite.adapter.enumerable.EnumerableRules;
+import org.apache.calcite.adapter.java.AbstractQueryableTable;
+import org.apache.calcite.config.CalciteConnectionProperty;
+import org.apache.calcite.config.Lex;
+import org.apache.calcite.interpreter.Row;
+import org.apache.calcite.jdbc.CalciteSchema;
+import org.apache.calcite.linq4j.Enumerable;
+import org.apache.calcite.linq4j.Linq4j;
+import org.apache.calcite.linq4j.QueryProvider;
+import org.apache.calcite.linq4j.Queryable;
+import org.apache.calcite.plan.RelOptPlanner;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeFactory;
+import org.apache.calcite.runtime.Hook;
+import org.apache.calcite.schema.QueryableTable;
+import org.apache.calcite.schema.Schema;
+import org.apache.calcite.schema.SchemaPlus;
+import org.apache.calcite.schema.Table;
+import org.apache.calcite.schema.impl.AbstractSchema;
+import org.apache.calcite.sql.parser.SqlParseException;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.calcite.tools.RelConversionException;
+import org.apache.calcite.tools.ValidationException;
+
+import com.google.common.collect.ImmutableMap;
+
+import org.junit.jupiter.api.Test;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Function;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Test class for CALCITE-3094.
+ */
+public class LargeGeneratedJoinTest {
+
+  /**
+   * Marker interface for Field.
+   */
+  interface FieldT extends BiConsumer<RelDataTypeFactory, 
RelDataTypeFactory.Builder> {
+  }
+
+  /**
+   * Marker interface for Row.
+   */
+  interface RowT extends Function<RelDataTypeFactory, RelDataType> {
+  }
+
+  static FieldT field(String name) {
+    return (tf, b) -> b.add(name, SqlTypeName.VARCHAR);
+  }
+
+  static RowT row(FieldT... fields) {
+    return tf -> {
+      RelDataTypeFactory.Builder builder = tf.builder();
+      for (FieldT f : fields) {
+        f.accept(tf, builder);
+      }
+      return builder.build();
+    };
+  }
+
+  private static QueryableTable tab(int fieldCount) {
+    List<Row> lRow = new ArrayList<>();
+    for (int r = 0; r < 2; r++) {
+      Object[] current = new Object[fieldCount];
+      for (int i = 0; i < fieldCount; i++) {
+        current[i] = "v" + i;
+      }
+      lRow.add(Row.of(current));
+    }
+
+    List<FieldT> fields = new ArrayList<>();
+    for (int i = 0; i < fieldCount; i++) {
+      fields.add(field("F_" + i));
+    }
+
+    final Enumerable<?> enumerable = Linq4j.asEnumerable(lRow);
+    return new AbstractQueryableTable(Row.class) {
+
+      @Override public RelDataType getRowType(RelDataTypeFactory typeFactory) {
+        return row(fields.toArray(new FieldT[fieldCount])).apply(typeFactory);
+      }
+
+      @Override public <T> Queryable<T> asQueryable(QueryProvider 
queryProvider, SchemaPlus schema,
+          String tableName) {
+        return (Queryable<T>) enumerable.asQueryable();
+      }
+    };
+  }
+
+  @Test public void test() throws SqlParseException, RelConversionException, 
ValidationException {
+    Schema rootSchema = new AbstractSchema() {
+      @Override protected Map<String, Table> getTableMap() {
+        return ImmutableMap.of("T0", tab(100),
+            "T1", tab(101));
+      }
+    };
+
+    final CalciteSchema sp = CalciteSchema.createRootSchema(false, true);
+    sp.add("ROOT", rootSchema);
+
+    String sql = "SELECT * \n"
+        + "FROM ROOT.T0 \n"
+        + "JOIN ROOT.T1 \n"
+        // + "ON ROOT.T0.F_0 = ROOT.T1.F_0";

Review Comment:
   Removed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to