[jira] [Commented] (CALCITE-3005) Implement string functions: LEFT, RIGHT

2019-06-09 Thread Julian Hyde (JIRA)


[ 
https://issues.apache.org/jira/browse/CALCITE-3005?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16859755#comment-16859755
 ] 

Julian Hyde commented on CALCITE-3005:
--

Yes. My bad. I have a fix and I’m testing now. 

> Implement string functions: LEFT, RIGHT
> ---
>
> Key: CALCITE-3005
> URL: https://issues.apache.org/jira/browse/CALCITE-3005
> Project: Calcite
>  Issue Type: New Feature
>Reporter: Forward Xu
>Assignee: Forward Xu
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.20.0
>
>  Time Spent: 6h 50m
>  Remaining Estimate: 0h
>
> Some string functions including LEFT, RIGHT are not implemented now. It would 
> be great if these functions can be implemented.
> [{{LEFT(_str_}},_{{len}}_)|https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_left]
> Returns the leftmost _{{len}}_ characters from the string _{{str}}_, or 
> {{NULL}} if any argument is {{NULL}}.
> [{{RIGHT(_str_}},_{{len}}_)|https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_right]
> Returns the rightmost _{{len}}_ characters from the string _{{str}}_, or 
> {{NULL}} if any argument is {{NULL}}.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-3121) VolcanoPlanner hangs due to removing ORDER BY from sub-query

2019-06-09 Thread Bohdan Kazydub (JIRA)


[ 
https://issues.apache.org/jira/browse/CALCITE-3121?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16859747#comment-16859747
 ] 

Bohdan Kazydub commented on CALCITE-3121:
-

[~hyuan], as was described in description, the test succeeds without 
CALCITE-2798 but fails with it. The query you wrote is the same bug, which 
starts to reproduce for more cases with the changes in CALCITE-2798.

> VolcanoPlanner hangs due to removing ORDER BY from sub-query
> 
>
> Key: CALCITE-3121
> URL: https://issues.apache.org/jira/browse/CALCITE-3121
> Project: Calcite
>  Issue Type: Bug
>Reporter: Bohdan Kazydub
>Assignee: Danny Chan
>Priority: Blocker
>
> After the fix for CALCITE-2798 some queries hang during planning in 
> VolcanoPlanner (similar issue was reported in CALCITE-2223).
> Here is a test case which should be added to the {{RelOptRulesTest}} class:
> {code:java}
>   @Test public void testSubQueryWithOrderByHang() {
> String sql = "select n.n_regionkey from ( select * from "
> + "( select * from sales.customer) t order by t.n_regionkey) n where 
> n.n_nationkey >1 ";
> VolcanoPlanner planner = new VolcanoPlanner(null, null);
> planner.addRelTraitDef(ConventionTraitDef.INSTANCE);
> Tester dynamicTester = createDynamicTester().withDecorrelation(true)
> .withClusterFactory(
> relOptCluster -> RelOptCluster.create(planner, 
> relOptCluster.getRexBuilder()));
> RelRoot root = dynamicTester.convertSqlToRel(sql);
> String planBefore = NL + RelOptUtil.toString(root.rel);
> getDiffRepos().assertEquals("planBefore", "${planBefore}", planBefore);
> PushProjector.ExprCondition exprCondition = expr -> {
>   if (expr instanceof RexCall) {
> RexCall call = (RexCall) expr;
> return 
> "item".equals(call.getOperator().getName().toLowerCase(Locale.ROOT));
>   }
>   return false;
> };
> RuleSet ruleSet =
> RuleSets.ofList(
> FilterProjectTransposeRule.INSTANCE,
> FilterMergeRule.INSTANCE,
> ProjectMergeRule.INSTANCE,
> new ProjectFilterTransposeRule(Project.class, Filter .class,
> RelFactories.LOGICAL_BUILDER, exprCondition),
> EnumerableRules.ENUMERABLE_PROJECT_RULE,
> EnumerableRules.ENUMERABLE_FILTER_RULE,
> EnumerableRules.ENUMERABLE_SORT_RULE,
> EnumerableRules.ENUMERABLE_LIMIT_RULE,
> EnumerableRules.ENUMERABLE_TABLE_SCAN_RULE);
> Program program = Programs.of(ruleSet);
> RelTraitSet toTraits =
> root.rel.getCluster().traitSet()
> .replace(0, EnumerableConvention.INSTANCE);
> RelNode relAfter = program.run(planner, root.rel, toTraits,
> Collections.emptyList(), Collections.emptyList());
> String planAfter = NL + RelOptUtil.toString(relAfter);
> getDiffRepos().assertEquals("planAfter", "${planAfter}", planAfter);
>   }
> {code}
> Please note that if {{LIMIT }} is added to the sub-query with order by 
> (so it is not removed due to the fix for CALCITE-2798) the test succeeds.
> Though the issue with hanging is more general, I think that if it wouldn't be 
> fixed, the fix for CALCITE-2798 should be reverted to reduce cases when 
> planner may hang.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2822) Allow multi-join rules to be used with any project/filter

2019-06-09 Thread Danny Chan (JIRA)


[ 
https://issues.apache.org/jira/browse/CALCITE-2822?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16859694#comment-16859694
 ] 

Danny Chan commented on CALCITE-2822:
-

The master branch build fails from this 
[https://github.com/apache/calcite/commit/0cb51c64715dd45f8bbcd533cc9096b4bb7b70af]
 commit, with failed case:

CalciteSqlOperatorTest#testSimilarToOperator
{code:java}
tester.checkFails(
"'yd3223' similar to '[:LOWER:]{2}[:DIGIT:]{,5}'",
"Illegal repetition near index 20\n"
+ "\\[\\:LOWER\\:\\]\\{2\\}\\[\\:DIGIT\\:\\]\\{,5\\}\n"
+ " \\^",
true);
{code}
I have no idea if this failure comes from this commit, [~siddteotia] can you 
take a look ?

> Allow multi-join rules to be used with any project/filter
> -
>
> Key: CALCITE-2822
> URL: https://issues.apache.org/jira/browse/CALCITE-2822
> Project: Calcite
>  Issue Type: Task
>  Components: core
>Reporter: Siddharth Teotia
>Priority: Minor
>  Labels: pull-request-available
> Fix For: 1.20.0
>
>  Time Spent: 5h 50m
>  Remaining Estimate: 0h
>
> Allow multi join rules to be used with any subclass of Project or Filter 
> instead of having just LogicalProject and LogicalFilter



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2744) RelDecorrelator use wrong output map for LogicalAggregate decorrelate

2019-06-09 Thread Danny Chan (JIRA)


[ 
https://issues.apache.org/jira/browse/CALCITE-2744?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16859670#comment-16859670
 ] 

Danny Chan commented on CALCITE-2744:
-

[~julianhyde] I fired  a fix in [https://github.com/apache/calcite/pull/1263], 
can you take a look ?

> RelDecorrelator use wrong output map for LogicalAggregate decorrelate
> -
>
> Key: CALCITE-2744
> URL: https://issues.apache.org/jira/browse/CALCITE-2744
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.20.0
>Reporter: Wei Zhong
>Assignee: Danny Chan
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.20.0
>
>  Time Spent: 2.5h
>  Remaining Estimate: 0h
>
> when running the following test in org.apache.calcite.test.RelOptRulesTest, 
> we will get a RuntimeException: 
> {code:java}
> @Test public void testDecorrelateWith2ParamsAgg() {
>   final HepProgram preProgram =
>   HepProgram.builder()
>   .addRuleInstance(FilterProjectTransposeRule.INSTANCE)
>   .addRuleInstance(FilterJoinRule.FILTER_ON_JOIN)
>   .addRuleInstance(ProjectMergeRule.INSTANCE)
>   .build();
>   final HepProgram program =
>   HepProgram.builder()
>   .addRuleInstance(SemiJoinRule.PROJECT)
>   .build();
>   final String sql = "select * from dept where exists (\n"
>   + "select UDF_AVG(sal, sal + 1) from sales.emp\n"
>   + "where emp.deptno = dept.deptno\n"
>   + "and emp.sal > 100)";
>   Sql sqlTest = sql(sql)
>   .withDecorrelation(true)
>   .withTrim(true)
>   .withPre(preProgram)
>   .with(program);
>   sqlTest.check();
> }
> {code}
> UDF_AVG code in MockSqlOperatorTable: 
> {code:java}
> public static void addRamp(MockSqlOperatorTable opTab) {
>   // Don't use anonymous inner classes. They can't be instantiated
>   // using reflection when we are deserializing from JSON.
>   opTab.addOperator(new RampFunction());
>   opTab.addOperator(new DedupFunction());
>   opTab.addOperator(UDF_AVG);
> }
> public static final SqlFunction UDF_AVG = new SqlAggFunction(
> "UDF_AVG",
> null,
> SqlKind.OTHER_FUNCTION,
> ReturnTypes.AVG_AGG_FUNCTION,
> null,
> OperandTypes.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC),
> SqlFunctionCategory.NUMERIC,
> false,
> false,
> Optionality.FORBIDDEN) {
>   @Override public boolean isDeterministic() {
> return false;
>   }
> };
> {code}
> The RuntimeExcpetion detail:
> {code:java}
> java.lang.RuntimeException: While invoking method 'public 
> org.apache.calcite.sql2rel.RelDecorrelator$Frame 
> org.apache.calcite.sql2rel.RelDecorrelator.decorrelateRel(org.apache.calcite.rel.logical.LogicalProject)'
> at org.apache.calcite.util.ReflectUtil$2.invoke(ReflectUtil.java:527)
> at 
> org.apache.calcite.sql2rel.RelDecorrelator.getInvoke(RelDecorrelator.java:613)
> at 
> org.apache.calcite.sql2rel.RelDecorrelator.decorrelate(RelDecorrelator.java:254)
> at 
> org.apache.calcite.sql2rel.RelDecorrelator.decorrelateQuery(RelDecorrelator.java:214)
> at 
> org.apache.calcite.sql2rel.SqlToRelConverter.decorrelateQuery(SqlToRelConverter.java:3037)
> at 
> org.apache.calcite.sql2rel.SqlToRelConverter.decorrelate(SqlToRelConverter.java:481)
> at 
> org.apache.calcite.test.SqlToRelTestBase$TesterImpl.convertSqlToRel(SqlToRelTestBase.java:615)
> at 
> org.apache.calcite.test.RelOptTestBase.checkPlanning(RelOptTestBase.java:177)
> at org.apache.calcite.test.RelOptTestBase$Sql.check(RelOptTestBase.java:334)
> at org.apache.calcite.test.RelOptTestBase$Sql.check(RelOptTestBase.java:317)
> at 
> org.apache.calcite.test.RelOptRulesTest.testDecorrelateWith2ParamsAgg(RelOptRulesTest.java:4286)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at 
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
> at 
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> at 
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
> at 
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
> at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
> at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)

[jira] [Commented] (CALCITE-3005) Implement string functions: LEFT, RIGHT

2019-06-09 Thread Danny Chan (JIRA)


[ 
https://issues.apache.org/jira/browse/CALCITE-3005?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16859664#comment-16859664
 ] 

Danny Chan commented on CALCITE-3005:
-

An compile warning of JavaCC throws:
{code:java}
Warning: Choice conflict involving two expansions at
line 6350, column 13 and line 6353, column 13 respectively.
A common prefix is: "LEFT"
Consider using a lookahead of 2 for earlier expansion.
{code}
We need to fix this.

> Implement string functions: LEFT, RIGHT
> ---
>
> Key: CALCITE-3005
> URL: https://issues.apache.org/jira/browse/CALCITE-3005
> Project: Calcite
>  Issue Type: New Feature
>Reporter: Forward Xu
>Assignee: Forward Xu
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.20.0
>
>  Time Spent: 6h 50m
>  Remaining Estimate: 0h
>
> Some string functions including LEFT, RIGHT are not implemented now. It would 
> be great if these functions can be implemented.
> [{{LEFT(_str_}},_{{len}}_)|https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_left]
> Returns the leftmost _{{len}}_ characters from the string _{{str}}_, or 
> {{NULL}} if any argument is {{NULL}}.
> [{{RIGHT(_str_}},_{{len}}_)|https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_right]
> Returns the rightmost _{{len}}_ characters from the string _{{str}}_, or 
> {{NULL}} if any argument is {{NULL}}.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2744) RelDecorrelator use wrong output map for LogicalAggregate decorrelate

2019-06-09 Thread Julian Hyde (JIRA)


[ 
https://issues.apache.org/jira/browse/CALCITE-2744?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16859624#comment-16859624
 ] 

Julian Hyde commented on CALCITE-2744:
--

While you're in that code, modify the javadoc of MY_AVG and explain why it is 
special.

> RelDecorrelator use wrong output map for LogicalAggregate decorrelate
> -
>
> Key: CALCITE-2744
> URL: https://issues.apache.org/jira/browse/CALCITE-2744
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.20.0
>Reporter: Wei Zhong
>Assignee: Danny Chan
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.20.0
>
>  Time Spent: 2h 20m
>  Remaining Estimate: 0h
>
> when running the following test in org.apache.calcite.test.RelOptRulesTest, 
> we will get a RuntimeException: 
> {code:java}
> @Test public void testDecorrelateWith2ParamsAgg() {
>   final HepProgram preProgram =
>   HepProgram.builder()
>   .addRuleInstance(FilterProjectTransposeRule.INSTANCE)
>   .addRuleInstance(FilterJoinRule.FILTER_ON_JOIN)
>   .addRuleInstance(ProjectMergeRule.INSTANCE)
>   .build();
>   final HepProgram program =
>   HepProgram.builder()
>   .addRuleInstance(SemiJoinRule.PROJECT)
>   .build();
>   final String sql = "select * from dept where exists (\n"
>   + "select UDF_AVG(sal, sal + 1) from sales.emp\n"
>   + "where emp.deptno = dept.deptno\n"
>   + "and emp.sal > 100)";
>   Sql sqlTest = sql(sql)
>   .withDecorrelation(true)
>   .withTrim(true)
>   .withPre(preProgram)
>   .with(program);
>   sqlTest.check();
> }
> {code}
> UDF_AVG code in MockSqlOperatorTable: 
> {code:java}
> public static void addRamp(MockSqlOperatorTable opTab) {
>   // Don't use anonymous inner classes. They can't be instantiated
>   // using reflection when we are deserializing from JSON.
>   opTab.addOperator(new RampFunction());
>   opTab.addOperator(new DedupFunction());
>   opTab.addOperator(UDF_AVG);
> }
> public static final SqlFunction UDF_AVG = new SqlAggFunction(
> "UDF_AVG",
> null,
> SqlKind.OTHER_FUNCTION,
> ReturnTypes.AVG_AGG_FUNCTION,
> null,
> OperandTypes.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC),
> SqlFunctionCategory.NUMERIC,
> false,
> false,
> Optionality.FORBIDDEN) {
>   @Override public boolean isDeterministic() {
> return false;
>   }
> };
> {code}
> The RuntimeExcpetion detail:
> {code:java}
> java.lang.RuntimeException: While invoking method 'public 
> org.apache.calcite.sql2rel.RelDecorrelator$Frame 
> org.apache.calcite.sql2rel.RelDecorrelator.decorrelateRel(org.apache.calcite.rel.logical.LogicalProject)'
> at org.apache.calcite.util.ReflectUtil$2.invoke(ReflectUtil.java:527)
> at 
> org.apache.calcite.sql2rel.RelDecorrelator.getInvoke(RelDecorrelator.java:613)
> at 
> org.apache.calcite.sql2rel.RelDecorrelator.decorrelate(RelDecorrelator.java:254)
> at 
> org.apache.calcite.sql2rel.RelDecorrelator.decorrelateQuery(RelDecorrelator.java:214)
> at 
> org.apache.calcite.sql2rel.SqlToRelConverter.decorrelateQuery(SqlToRelConverter.java:3037)
> at 
> org.apache.calcite.sql2rel.SqlToRelConverter.decorrelate(SqlToRelConverter.java:481)
> at 
> org.apache.calcite.test.SqlToRelTestBase$TesterImpl.convertSqlToRel(SqlToRelTestBase.java:615)
> at 
> org.apache.calcite.test.RelOptTestBase.checkPlanning(RelOptTestBase.java:177)
> at org.apache.calcite.test.RelOptTestBase$Sql.check(RelOptTestBase.java:334)
> at org.apache.calcite.test.RelOptTestBase$Sql.check(RelOptTestBase.java:317)
> at 
> org.apache.calcite.test.RelOptRulesTest.testDecorrelateWith2ParamsAgg(RelOptRulesTest.java:4286)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at 
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
> at 
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> at 
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
> at 
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
> at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
> at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
> at org.j

[jira] [Reopened] (CALCITE-2744) RelDecorrelator use wrong output map for LogicalAggregate decorrelate

2019-06-09 Thread Julian Hyde (JIRA)


 [ 
https://issues.apache.org/jira/browse/CALCITE-2744?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Julian Hyde reopened CALCITE-2744:
--

Re-opened because of deprecation warning.

> RelDecorrelator use wrong output map for LogicalAggregate decorrelate
> -
>
> Key: CALCITE-2744
> URL: https://issues.apache.org/jira/browse/CALCITE-2744
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.20.0
>Reporter: Wei Zhong
>Assignee: Danny Chan
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.20.0
>
>  Time Spent: 2h 20m
>  Remaining Estimate: 0h
>
> when running the following test in org.apache.calcite.test.RelOptRulesTest, 
> we will get a RuntimeException: 
> {code:java}
> @Test public void testDecorrelateWith2ParamsAgg() {
>   final HepProgram preProgram =
>   HepProgram.builder()
>   .addRuleInstance(FilterProjectTransposeRule.INSTANCE)
>   .addRuleInstance(FilterJoinRule.FILTER_ON_JOIN)
>   .addRuleInstance(ProjectMergeRule.INSTANCE)
>   .build();
>   final HepProgram program =
>   HepProgram.builder()
>   .addRuleInstance(SemiJoinRule.PROJECT)
>   .build();
>   final String sql = "select * from dept where exists (\n"
>   + "select UDF_AVG(sal, sal + 1) from sales.emp\n"
>   + "where emp.deptno = dept.deptno\n"
>   + "and emp.sal > 100)";
>   Sql sqlTest = sql(sql)
>   .withDecorrelation(true)
>   .withTrim(true)
>   .withPre(preProgram)
>   .with(program);
>   sqlTest.check();
> }
> {code}
> UDF_AVG code in MockSqlOperatorTable: 
> {code:java}
> public static void addRamp(MockSqlOperatorTable opTab) {
>   // Don't use anonymous inner classes. They can't be instantiated
>   // using reflection when we are deserializing from JSON.
>   opTab.addOperator(new RampFunction());
>   opTab.addOperator(new DedupFunction());
>   opTab.addOperator(UDF_AVG);
> }
> public static final SqlFunction UDF_AVG = new SqlAggFunction(
> "UDF_AVG",
> null,
> SqlKind.OTHER_FUNCTION,
> ReturnTypes.AVG_AGG_FUNCTION,
> null,
> OperandTypes.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC),
> SqlFunctionCategory.NUMERIC,
> false,
> false,
> Optionality.FORBIDDEN) {
>   @Override public boolean isDeterministic() {
> return false;
>   }
> };
> {code}
> The RuntimeExcpetion detail:
> {code:java}
> java.lang.RuntimeException: While invoking method 'public 
> org.apache.calcite.sql2rel.RelDecorrelator$Frame 
> org.apache.calcite.sql2rel.RelDecorrelator.decorrelateRel(org.apache.calcite.rel.logical.LogicalProject)'
> at org.apache.calcite.util.ReflectUtil$2.invoke(ReflectUtil.java:527)
> at 
> org.apache.calcite.sql2rel.RelDecorrelator.getInvoke(RelDecorrelator.java:613)
> at 
> org.apache.calcite.sql2rel.RelDecorrelator.decorrelate(RelDecorrelator.java:254)
> at 
> org.apache.calcite.sql2rel.RelDecorrelator.decorrelateQuery(RelDecorrelator.java:214)
> at 
> org.apache.calcite.sql2rel.SqlToRelConverter.decorrelateQuery(SqlToRelConverter.java:3037)
> at 
> org.apache.calcite.sql2rel.SqlToRelConverter.decorrelate(SqlToRelConverter.java:481)
> at 
> org.apache.calcite.test.SqlToRelTestBase$TesterImpl.convertSqlToRel(SqlToRelTestBase.java:615)
> at 
> org.apache.calcite.test.RelOptTestBase.checkPlanning(RelOptTestBase.java:177)
> at org.apache.calcite.test.RelOptTestBase$Sql.check(RelOptTestBase.java:334)
> at org.apache.calcite.test.RelOptTestBase$Sql.check(RelOptTestBase.java:317)
> at 
> org.apache.calcite.test.RelOptRulesTest.testDecorrelateWith2ParamsAgg(RelOptRulesTest.java:4286)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at 
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
> at 
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> at 
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
> at 
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
> at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
> at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
> at org.junit.runners.ParentRunner.acce

[jira] [Commented] (CALCITE-2744) RelDecorrelator use wrong output map for LogicalAggregate decorrelate

2019-06-09 Thread Julian Hyde (JIRA)


[ 
https://issues.apache.org/jira/browse/CALCITE-2744?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16859621#comment-16859621
 ] 

Julian Hyde commented on CALCITE-2744:
--

* It's usually not a good idea if the commit message describes the code change 
that you made. A better commit message (and JIRA case title) would have 
described the bug that the end-user sees, for example "RelDecorrelator throws 
when decorrelating an aggregate function with more than one argument". 
* This commit adds a call to a deprecated API (line 136 of 
MockSqlOperatorTable). Please fix ASAP.

> RelDecorrelator use wrong output map for LogicalAggregate decorrelate
> -
>
> Key: CALCITE-2744
> URL: https://issues.apache.org/jira/browse/CALCITE-2744
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.20.0
>Reporter: Wei Zhong
>Assignee: Danny Chan
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.20.0
>
>  Time Spent: 2h 20m
>  Remaining Estimate: 0h
>
> when running the following test in org.apache.calcite.test.RelOptRulesTest, 
> we will get a RuntimeException: 
> {code:java}
> @Test public void testDecorrelateWith2ParamsAgg() {
>   final HepProgram preProgram =
>   HepProgram.builder()
>   .addRuleInstance(FilterProjectTransposeRule.INSTANCE)
>   .addRuleInstance(FilterJoinRule.FILTER_ON_JOIN)
>   .addRuleInstance(ProjectMergeRule.INSTANCE)
>   .build();
>   final HepProgram program =
>   HepProgram.builder()
>   .addRuleInstance(SemiJoinRule.PROJECT)
>   .build();
>   final String sql = "select * from dept where exists (\n"
>   + "select UDF_AVG(sal, sal + 1) from sales.emp\n"
>   + "where emp.deptno = dept.deptno\n"
>   + "and emp.sal > 100)";
>   Sql sqlTest = sql(sql)
>   .withDecorrelation(true)
>   .withTrim(true)
>   .withPre(preProgram)
>   .with(program);
>   sqlTest.check();
> }
> {code}
> UDF_AVG code in MockSqlOperatorTable: 
> {code:java}
> public static void addRamp(MockSqlOperatorTable opTab) {
>   // Don't use anonymous inner classes. They can't be instantiated
>   // using reflection when we are deserializing from JSON.
>   opTab.addOperator(new RampFunction());
>   opTab.addOperator(new DedupFunction());
>   opTab.addOperator(UDF_AVG);
> }
> public static final SqlFunction UDF_AVG = new SqlAggFunction(
> "UDF_AVG",
> null,
> SqlKind.OTHER_FUNCTION,
> ReturnTypes.AVG_AGG_FUNCTION,
> null,
> OperandTypes.family(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC),
> SqlFunctionCategory.NUMERIC,
> false,
> false,
> Optionality.FORBIDDEN) {
>   @Override public boolean isDeterministic() {
> return false;
>   }
> };
> {code}
> The RuntimeExcpetion detail:
> {code:java}
> java.lang.RuntimeException: While invoking method 'public 
> org.apache.calcite.sql2rel.RelDecorrelator$Frame 
> org.apache.calcite.sql2rel.RelDecorrelator.decorrelateRel(org.apache.calcite.rel.logical.LogicalProject)'
> at org.apache.calcite.util.ReflectUtil$2.invoke(ReflectUtil.java:527)
> at 
> org.apache.calcite.sql2rel.RelDecorrelator.getInvoke(RelDecorrelator.java:613)
> at 
> org.apache.calcite.sql2rel.RelDecorrelator.decorrelate(RelDecorrelator.java:254)
> at 
> org.apache.calcite.sql2rel.RelDecorrelator.decorrelateQuery(RelDecorrelator.java:214)
> at 
> org.apache.calcite.sql2rel.SqlToRelConverter.decorrelateQuery(SqlToRelConverter.java:3037)
> at 
> org.apache.calcite.sql2rel.SqlToRelConverter.decorrelate(SqlToRelConverter.java:481)
> at 
> org.apache.calcite.test.SqlToRelTestBase$TesterImpl.convertSqlToRel(SqlToRelTestBase.java:615)
> at 
> org.apache.calcite.test.RelOptTestBase.checkPlanning(RelOptTestBase.java:177)
> at org.apache.calcite.test.RelOptTestBase$Sql.check(RelOptTestBase.java:334)
> at org.apache.calcite.test.RelOptTestBase$Sql.check(RelOptTestBase.java:317)
> at 
> org.apache.calcite.test.RelOptRulesTest.testDecorrelateWith2ParamsAgg(RelOptRulesTest.java:4286)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at 
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
> at 
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> at 
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
> at 
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
> at 
> 

[jira] [Commented] (CALCITE-2804) Druid adapter: Cast does not work when casting to timestamp

2019-06-09 Thread Justin Szeluga (JIRA)


[ 
https://issues.apache.org/jira/browse/CALCITE-2804?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16859566#comment-16859566
 ] 

Justin Szeluga commented on CALCITE-2804:
-

I updated the pull request ([https://github.com/apache/calcite/pull/1262)] with 
the latest changes. The continuous integration seems to be failing for an 
unrelated test

> Druid adapter: Cast does not work when casting to timestamp
> ---
>
> Key: CALCITE-2804
> URL: https://issues.apache.org/jira/browse/CALCITE-2804
> Project: Calcite
>  Issue Type: Bug
>Affects Versions: 1.18.0
>Reporter: Justin Szeluga
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.20.0
>
>  Time Spent: 3h
>  Remaining Estimate: 0h
>
> When trying to execute a simple statement of 
> {code:java}
> select cast("__time" as timestamp) from my_datasource limit 10;{code}
> the query fails with a 500 error
>  
> {code:java}
> Caused by: java.io.IOException: Server returned HTTP response code: 500 for 
> URL: http://localhost:58082/druid/v2/?pretty
> at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
> at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
> at org.apache.calcite.runtime.HttpUtils.executeMethod(HttpUtils.java:137)
> at org.apache.calcite.runtime.HttpUtils.post(HttpUtils.java:110)
> at 
> org.apache.calcite.adapter.druid.DruidConnectionImpl.request(DruidConnectionImpl.java:109)
> ... 29 more
> {code}
> because the JSON generated is incorrect. Here is the generated JSON
>  
>  
> {code:java}
> {
>   "queryType": "scan",
>   "dataSource": "my_datasource",
>   "intervals": [
> "1900-01-01T00:00:00.000Z/3000-01-01T00:00:00.000Z"
>   ],
>   "virtualColumns": [
> {
>   "type": "expression",
>   "name": "vc",
>   "expression": 
> "timestamp_parse(timestamp_format(\"__time\",'-MM-dd\\u0027T\\u0027HH:mm:ss.SSS\\u0027Z\\u0027','America/New_York'),'','UTC')",
>   "outputType": "LONG"
> }
>   ],
>   "columns": [
> "vc"
>   ],
>   "resultFormat": "compactedList",
>   "limit": 10
> }
> {code}
> There are two problems. -First, the "__time" dimension is not formatted 
> correctly in timestamp_format. The escaped quotes need to be removed.-
> Also, the call to timestamp_parse is incorrect. If a timezone is going to be 
> provided then a date time format needs to be provided as well. Currently, it 
> is only empty string
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-3117) Distinguish Calcite's public APIs

2019-06-09 Thread Volodymyr Vysotskyi (JIRA)


[ 
https://issues.apache.org/jira/browse/CALCITE-3117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16859458#comment-16859458
 ] 

Volodymyr Vysotskyi commented on CALCITE-3117:
--

Hi all, here is the list of some Calcite classes from calcite-code module used 
by Drill (grouped by packages):
{noformat}
org.apache.calcite.adapter.enumerable.EnumerableConvention - used enum elements
org.apache.calcite.adapter.enumerable.EnumerableTableScan - extends and 
overrides copy(), explainTerms() methods, redular usage (constructing, 
specifying in rules)
org.apache.calcite.adapter.java.JavaTypeFactory - used as interface
org.apache.calcite.adapter.jdbc.JdbcConvention - extends and overrides 
register(), used as type
org.apache.calcite.adapter.jdbc.JdbcImplementor - constructing instances, uses 
visitChild() method
org.apache.calcite.adapter.jdbc.JdbcRules - used rules() method, constructs 
JdbcRules.JdbcProject and JdbcRules.JdbcFilter instances
org.apache.calcite.adapter.jdbc.JdbcSchema - creates instances, uses 
createDialect() method
org.apache.calcite.config.CalciteConnectionConfig - used as interface
org.apache.calcite.config.CalciteConnectionConfigImpl - constructs new 
instances, used in method signatures
org.apache.calcite.config.CalciteConnectionProperty - used some elements from 
enum

org.apache.calcite.jdbc.JavaTypeFactoryImpl - constructs new instances

org.apache.calcite.plan.hep.HepMatchOrder - used enum elements
org.apache.calcite.plan.hep.HepPlanner - constror
org.apache.calcite.plan.hep.HepProgramBuilder - constructor, addMatchOrder(), 
addRuleInstance(), build() methods
org.apache.calcite.plan.hep.HepRelVertex - used type, ised getCurrentRel() 
method

org.apache.calcite.plan.volcano.AbstractConverter - constructs 
AbstractConverter.ExpandConversionRule
org.apache.calcite.plan.volcano.RelSubset - used as type, getRelList(), 
getBest(), getOriginal()
org.apache.calcite.plan.volcano.VolcanoPlanner - used constructor, 
setExecutor(), clearRelTraitDefs(), addRelTraitDef()

org.apache.calcite.plan.Context - provides implementations
org.apache.calcite.plan.Contexts - uses of() method(s)
org.apache.calcite.plan.Convention - provides custom implementation, uses type
org.apache.calcite.plan.ConventionTraitDef - uses its INSTANCE constant
org.apache.calcite.plan.RelOptCluster - uses create(), getPlanner(), 
getTypeFactory(), getRexBuilder(), setMetadataProvider(), createCorrel(), 
traitSet(), traitSetOf() methods
org.apache.calcite.plan.RelOptCost - provides custom implementation
org.apache.calcite.plan.RelOptCostFactory - provides custom implementation
org.apache.calcite.plan.RelOptPlanner - used as interface
org.apache.calcite.plan.RelOptRule - extends
org.apache.calcite.plan.RelOptRuleCall - used as type, used some methods
org.apache.calcite.plan.RelOptSchema - provides implementation
org.apache.calcite.plan.RelOptTable - uses some methods
org.apache.calcite.plan.RelOptUtil - uses some methods
org.apache.calcite.plan.RelTrait - provides implementation
org.apache.calcite.plan.RelTraitDef - extends and implements abstract methods
org.apache.calcite.plan.RelTraitSet

org.apache.calcite.prepare.CalciteCatalogReader - extends and overrides 
getTable(), getSchemaPaths() methods
org.apache.calcite.prepare.Prepare - uses PreparingTable interfase

org.apache.calcite.rel.convert.ConverterRule - extends

org.apache.calcite.rel.core - uses almost all classes from package

org.apache.calcite.rel.logical - uses almost all classes from package

org.apache.calcite.rel.metadata.ChainedRelMetadataProvider - uses of() method
org.apache.calcite.rel.metadata.DefaultRelMetadataProvider
org.apache.calcite.rel.metadata.JaninoRelMetadataProvider - uses of() method
org.apache.calcite.rel.metadata.ReflectiveRelMetadataProvider - uses 
reflectiveSource() method
org.apache.calcite.rel.metadata.RelMdDistinctRowCount - extends class and 
overrides some methods
org.apache.calcite.rel.metadata.RelMdRowCount - extends class and overrides 
some methods
org.apache.calcite.rel.metadata.RelMdUtil - uses some methods
org.apache.calcite.rel.metadata.RelMetadataProvider - used as interface
org.apache.calcite.rel.metadata.RelMetadataQuery

org.apache.calcite.rel.rules - uses a lot of classes

org.apache.calcite.rel.type.DynamicRecordType - extends class and overrides 
some methods
org.apache.calcite.rel.type.RelDataType - provides custom implementations
org.apache.calcite.rel.type.RelDataTypeFactory - used as interface
org.apache.calcite.rel.type.RelDataTypeFamily - provides custom implementations
org.apache.calcite.rel.type.RelDataTypeField - used as interface
org.apache.calcite.rel.type.RelDataTypeFieldImpl - used constructor, some 
methods
org.apache.calcite.rel.type.RelDataTypeImpl - extends class and overrides some 
methods
org.apache.calcite.rel.type.RelDataTypePrecedenceList - used as interface
org.apache.calcite.rel.type.RelDataTypeSystem - provide