Skip to content

Commit

Permalink
Merge branch 'master' of github.com:apache/calcite into CALCITE-1045
Browse files Browse the repository at this point in the history
# Conflicts:
#	core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml
  • Loading branch information
jamesstarr committed Jun 21, 2021
2 parents 932975f + 8430023 commit c6c6a08
Show file tree
Hide file tree
Showing 70 changed files with 22,205 additions and 20,335 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@ ij_java_ternary_operation_signs_on_next_line = true
ij_java_use_single_class_imports = true
ij_java_wrap_long_lines = true
ij_java_align_multiline_parameters = false

[*.xml]
indent_size = 2
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Apache Calcite
Copyright 2012-2020 The Apache Software Foundation
Copyright 2012-2021 The Apache Software Foundation

This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
Expand Down
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Apache Calcite release 1.26.0
Apache Calcite release 1.27.0

This is a source or binary distribution of Apache Calcite.

Expand Down
7 changes: 3 additions & 4 deletions core/src/main/java/org/apache/calcite/adapter/java/Array.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,19 @@
*/
package org.apache.calcite.adapter.java;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.FIELD;

/**
* Annotation that indicates that a field is an array type.
*/
@Target({FIELD })
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Array {
/** Component type. */
Class component();
Class<?> component();

/** Whether components may be null. */
boolean componentIsNullable() default false;
Expand Down
9 changes: 4 additions & 5 deletions core/src/main/java/org/apache/calcite/adapter/java/Map.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,22 @@
*/
package org.apache.calcite.adapter.java;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.FIELD;

/**
* Annotation that indicates that a field is a map type.
*/
@Target({FIELD })
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Map {
/** Key type. */
Class key();
Class<?> key();

/** Value type. */
Class value();
Class<?> value();

/** Whether keys may be null. */
boolean keyIsNullable() default true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.calcite.plan.RelOptCost;
import org.apache.calcite.plan.RelOptPlanner;
import org.apache.calcite.plan.RelOptRule;
import org.apache.calcite.plan.RelOptRuleCall;
import org.apache.calcite.plan.RelOptTable;
import org.apache.calcite.plan.RelRule;
import org.apache.calcite.plan.RelTraitSet;
Expand Down Expand Up @@ -361,6 +362,12 @@ private static boolean canJoinOnCondition(RexNode node) {
return false;
}
}

@Override public boolean matches(RelOptRuleCall call) {
Join join = call.rel(0);
JoinRelType joinType = join.getJoinType();
return ((JdbcConvention) getOutConvention()).dialect.supportsJoinType(joinType);
}
}

/** Join operator implemented in JDBC convention. */
Expand Down
35 changes: 20 additions & 15 deletions core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,15 @@
import org.apache.calcite.util.Pair;
import org.apache.calcite.util.Util;

import com.google.common.base.Suppliers;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.function.Supplier;

import static java.util.Objects.requireNonNull;

Expand All @@ -75,7 +78,9 @@
*/
public class JdbcTable extends AbstractQueryableTable
implements TranslatableTable, ScannableTable, ModifiableTable {
private @Nullable RelProtoDataType protoRowType;
@SuppressWarnings("methodref.receiver.bound.invalid")
private final Supplier<RelProtoDataType> protoRowTypeSupplier =
Suppliers.memoize(this::supplyProto);
public final JdbcSchema jdbcSchema;
public final String jdbcCatalogName;
public final String jdbcSchemaName;
Expand Down Expand Up @@ -112,25 +117,25 @@ public class JdbcTable extends AbstractQueryableTable
}

@Override public RelDataType getRowType(RelDataTypeFactory typeFactory) {
if (protoRowType == null) {
try {
protoRowType =
jdbcSchema.getRelDataType(
jdbcCatalogName,
jdbcSchemaName,
jdbcTableName);
} catch (SQLException e) {
throw new RuntimeException(
"Exception while reading definition of table '" + jdbcTableName
+ "'", e);
}
return protoRowTypeSupplier.get().apply(typeFactory);
}

private RelProtoDataType supplyProto() {
try {
return jdbcSchema.getRelDataType(
jdbcCatalogName,
jdbcSchemaName,
jdbcTableName);
} catch (SQLException e) {
throw new RuntimeException(
"Exception while reading definition of table '" + jdbcTableName
+ "'", e);
}
return protoRowType.apply(typeFactory);
}

private List<Pair<ColumnMetaData.Rep, Integer>> fieldClasses(
final JavaTypeFactory typeFactory) {
final RelDataType rowType = requireNonNull(protoRowType, "protoRowType").apply(typeFactory);
final RelDataType rowType = getRowType(typeFactory);
return Util.transform(rowType.getFieldList(), f -> {
final RelDataType type = f.getType();
final Class clazz = (Class) typeFactory.getJavaClass(type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ private static ImmutableList<Row> createRows(Compiler compiler,
scalar.execute(context, values);
final ImmutableList.Builder<Row> rows = ImmutableList.builder();
Object[] subValues = new Object[fieldCount];
for (int i = 0; i < values.length; i += fieldCount) {
System.arraycopy(values, i, subValues, 0, fieldCount);
for (int r = 0, n = tuples.size(); r < n; ++r) {
System.arraycopy(values, r * fieldCount, subValues, 0, fieldCount);
rows.add(Row.asCopy(subValues));
}
return rows.build();
Expand Down
Loading

0 comments on commit c6c6a08

Please sign in to comment.