Skip to content

Commit

Permalink
[CALCITE-2859] Centralize Calcite system properties
Browse files Browse the repository at this point in the history
1. Move all system properties with "calcite" namespace under a common class.
2. Improve the documentation (javadoc) of existing properties.
3. Add review comments regarding a few properties.
4. Deprecate SaffronProperties and move them all under CalciteSystemProperty.
  • Loading branch information
zabetak committed Feb 28, 2019
1 parent a2e9f82 commit 280642a
Show file tree
Hide file tree
Showing 59 changed files with 480 additions and 235 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.calcite.adapter.enumerable.JavaRowFormat;
import org.apache.calcite.adapter.enumerable.PhysType;
import org.apache.calcite.adapter.enumerable.PhysTypeImpl;
import org.apache.calcite.config.CalciteSystemProperty;
import org.apache.calcite.linq4j.tree.BlockBuilder;
import org.apache.calcite.linq4j.tree.Expression;
import org.apache.calcite.linq4j.tree.Expressions;
Expand All @@ -30,7 +31,6 @@
import org.apache.calcite.plan.RelOptCost;
import org.apache.calcite.plan.RelOptPlanner;
import org.apache.calcite.plan.RelTraitSet;
import org.apache.calcite.prepare.CalcitePrepareImpl;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.convert.ConverterImpl;
import org.apache.calcite.rel.metadata.RelMetadataQuery;
Expand Down Expand Up @@ -122,7 +122,7 @@ public Result implement(EnumerableRelImplementor implementor, Prefer pref) {
Expressions.call(table,
CassandraMethod.CASSANDRA_QUERYABLE_QUERY.method, fields,
selectFields, predicates, order, offset, fetch));
if (CalcitePrepareImpl.DEBUG) {
if (CalciteSystemProperty.DEBUG.value()) {
System.out.println("Cassandra: " + predicates);
}
Hook.QUERY_PLAN.run(predicates);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
*/
package org.apache.calcite.test;

import org.apache.calcite.config.CalciteSystemProperty;
import org.apache.calcite.util.Bug;
import org.apache.calcite.util.Sources;
import org.apache.calcite.util.TestUtil;
import org.apache.calcite.util.Util;

import org.apache.cassandra.config.DatabaseDescriptor;

Expand Down Expand Up @@ -82,8 +82,7 @@ public class CassandraAdapterTest {
* {@code false} otherwise
*/
private static boolean enabled() {
final boolean enabled =
Util.getBooleanProperty("calcite.test.cassandra", true);
final boolean enabled = CalciteSystemProperty.TEST_CASSANDRA.value();
Bug.upgrade("remove JDK version check once current adapter supports Cassandra 4.x");
final boolean compatibleJdk = TestUtil.getJavaMajorVersion() != 11
&& TestUtil.getJavaMajorVersion() != 12;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.calcite.adapter.enumerable.impl.AggAddContextImpl;
import org.apache.calcite.adapter.enumerable.impl.AggResultContextImpl;
import org.apache.calcite.adapter.java.JavaTypeFactory;
import org.apache.calcite.config.CalciteSystemProperty;
import org.apache.calcite.jdbc.JavaTypeFactoryImpl;
import org.apache.calcite.linq4j.Ord;
import org.apache.calcite.linq4j.function.Function0;
Expand All @@ -31,7 +32,6 @@
import org.apache.calcite.linq4j.tree.Types;
import org.apache.calcite.plan.RelOptCluster;
import org.apache.calcite.plan.RelTraitSet;
import org.apache.calcite.prepare.CalcitePrepareImpl;
import org.apache.calcite.rel.InvalidRelException;
import org.apache.calcite.rel.RelCollations;
import org.apache.calcite.rel.RelNode;
Expand Down Expand Up @@ -212,7 +212,7 @@ public Result implement(EnumerableRelImplementor implementor, Prefer pref) {
final List<Expression> decls = new ArrayList<>(state.size());
for (int i = 0; i < state.size(); i++) {
String aggName = "a" + agg.aggIdx;
if (CalcitePrepareImpl.DEBUG) {
if (CalciteSystemProperty.DEBUG.value()) {
aggName = Util.toJavaId(agg.call.getAggregation().getName(), 0)
.substring("ID$0$".length()) + aggName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.apache.calcite.DataContext;
import org.apache.calcite.avatica.Helper;
import org.apache.calcite.config.CalciteSystemProperty;
import org.apache.calcite.interpreter.Compiler;
import org.apache.calcite.interpreter.InterpretableConvention;
import org.apache.calcite.interpreter.InterpretableRel;
Expand All @@ -33,7 +34,6 @@
import org.apache.calcite.plan.ConventionTraitDef;
import org.apache.calcite.plan.RelOptCluster;
import org.apache.calcite.plan.RelTraitSet;
import org.apache.calcite.prepare.CalcitePrepareImpl;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.convert.ConverterImpl;
import org.apache.calcite.runtime.ArrayBindable;
Expand Down Expand Up @@ -92,7 +92,7 @@ public static Bindable toBindable(Map<String, Object> parameters,
final ClassDeclaration expr = relImplementor.implementRoot(rel, prefer);
String s = Expressions.toString(expr.memberDeclarations, "\n", false);

if (CalcitePrepareImpl.DEBUG) {
if (CalciteSystemProperty.DEBUG.value()) {
Util.debugCode(System.out, s);
}

Expand Down Expand Up @@ -133,7 +133,7 @@ static Bindable getBindable(ClassDeclaration expr, String s, int fieldCount)
? new Class[] {Bindable.class, Typed.class}
: new Class[] {ArrayBindable.class});
cbe.setParentClassLoader(EnumerableInterpretable.class.getClassLoader());
if (CalcitePrepareImpl.DEBUG) {
if (CalciteSystemProperty.DEBUG.value()) {
// Add line numbers to the generated janino class
cbe.setDebuggingInformation(true, true, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.calcite.adapter.enumerable.impl.WinAggResetContextImpl;
import org.apache.calcite.adapter.enumerable.impl.WinAggResultContextImpl;
import org.apache.calcite.adapter.java.JavaTypeFactory;
import org.apache.calcite.config.CalciteSystemProperty;
import org.apache.calcite.linq4j.tree.BinaryExpression;
import org.apache.calcite.linq4j.tree.BlockBuilder;
import org.apache.calcite.linq4j.tree.BlockStatement;
Expand All @@ -34,7 +35,6 @@
import org.apache.calcite.plan.RelOptCost;
import org.apache.calcite.plan.RelOptPlanner;
import org.apache.calcite.plan.RelTraitSet;
import org.apache.calcite.prepare.CalcitePrepareImpl;
import org.apache.calcite.rel.RelFieldCollation;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.core.AggregateCall;
Expand Down Expand Up @@ -798,7 +798,7 @@ public List<? extends Type> keyTypes() {
}
};
String aggName = "a" + agg.aggIdx;
if (CalcitePrepareImpl.DEBUG) {
if (CalciteSystemProperty.DEBUG.value()) {
aggName = Util.toJavaId(agg.call.getAggregation().getName(), 0)
.substring("ID$0$".length()) + aggName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.calcite.adapter.enumerable.PhysType;
import org.apache.calcite.adapter.enumerable.PhysTypeImpl;
import org.apache.calcite.adapter.java.JavaTypeFactory;
import org.apache.calcite.config.CalciteSystemProperty;
import org.apache.calcite.linq4j.tree.BlockBuilder;
import org.apache.calcite.linq4j.tree.ConstantExpression;
import org.apache.calcite.linq4j.tree.Expression;
Expand All @@ -35,7 +36,6 @@
import org.apache.calcite.plan.RelOptCost;
import org.apache.calcite.plan.RelOptPlanner;
import org.apache.calcite.plan.RelTraitSet;
import org.apache.calcite.prepare.CalcitePrepareImpl;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.convert.ConverterImpl;
import org.apache.calcite.rel.metadata.RelMetadataQuery;
Expand Down Expand Up @@ -94,7 +94,7 @@ public Result implement(EnumerableRelImplementor implementor, Prefer pref) {
(JdbcConvention) child.getConvention();
SqlString sqlString = generateSql(jdbcConvention.dialect);
String sql = sqlString.getSql();
if (CalcitePrepareImpl.DEBUG) {
if (CalciteSystemProperty.DEBUG.value()) {
System.out.println("[" + sql + "]");
}
Hook.QUERY_PLAN.run(sql);
Expand Down
Loading

0 comments on commit 280642a

Please sign in to comment.