[jira] [Created] (CALCITE-5669) Remove trivial correlates from the query plan

2023-04-21 Thread Stamatis Zampetakis (Jira)
Stamatis Zampetakis created CALCITE-5669:


 Summary: Remove trivial correlates from the query plan
 Key: CALCITE-5669
 URL: https://issues.apache.org/jira/browse/CALCITE-5669
 Project: Calcite
  Issue Type: Improvement
  Components: core
Reporter: Stamatis Zampetakis
Assignee: Stamatis Zampetakis


Consider the following query correlated query.
{code:sql}
select * from emp e where exists (select 1 from dept where empno=null)
{code}
The query basically returns an empty result cause {{empno=null}} is always 
false.

The plan for the query after applying the sub-query remove rule is shown below:
{noformat}
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], 
SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
  LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], 
SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], 
requiredColumns=[{0}])
  LogicalTableScan(table=[[CATALOG, SALES, EMP]])
  LogicalAggregate(group=[{0}])
LogicalProject(i=[true])
  LogicalFilter(condition=[=($cor0.EMPNO, null)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
{noformat}
After applying the reduce expressions rule the filter with the correlated 
condition will become false and the resulting plan would be the following.
{noformat}
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], 
SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
  LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], 
SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], 
requiredColumns=[{0}])
  LogicalTableScan(table=[[CATALOG, SALES, EMP]])
  LogicalAggregate(group=[{0}])
LogicalProject(i=[true])
  LogicalValues(tuples=[[]])
{noformat}
Observe that now we have a {{LogicalCorrelate}} but there is no real 
correlation in the plan since the correlation variable on the right side 
disappeared. Depending on how rules are applied and which rules are used 
similar "trivial" correlates may appear.

The goal of this ticket is to provide the means to get rid of them.

One option would be to add a new rule (e.g., {{CorrelateToJoinRule}}) which 
detects that a correlate does not have correlations in the right side and turn 
the correlation to a join; then we could employ other existing rules (such as 
PruneEmptyRules) for joins and remove the newly created join altogether.

Another option, would be to introduce new pruning rule(s) for correlate 
(similar to those for joins) that will remove the correlate when its input is 
an empty values expression.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


Jenkins build is back to normal : Calcite » Calcite-snapshots #412

2023-04-21 Thread Apache Jenkins Server
See 




[jira] [Created] (CALCITE-5668) When parsing SQL in PostgreSQL dialect, allow unquoted table names to contain dollar sign

2023-04-21 Thread Dmitry Sysolyatin (Jira)
Dmitry Sysolyatin created CALCITE-5668:
--

 Summary: When parsing SQL in PostgreSQL dialect, allow unquoted 
table names to contain dollar sign
 Key: CALCITE-5668
 URL: https://issues.apache.org/jira/browse/CALCITE-5668
 Project: Calcite
  Issue Type: Bug
  Components: babel
Affects Versions: 1.34.0
Reporter: Dmitry Sysolyatin


According PostgreSQL documentation [1]:
??SQL identifiers and key words must begin with a letter (a-z, but also letters 
with diacritical marks and non-Latin letters) or an underscore (_). Subsequent 
characters in an identifier or key word can be letters, underscores, digits 
(0-9), or dollar signs ($).??

To implement it, I suggest using the same approach as in CALCITE-4246.

[1] https://www.postgresql.org/docs/8.1/sql-syntax.html#SQL-SYNTAX-IDENTIFIERS



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


Build failed in Jenkins: Calcite » Calcite-snapshots #411

2023-04-21 Thread Apache Jenkins Server
See 


Changes:

[Stamatis Zampetakis] Disable JIRA worklog notifications for GitHub PRs


--
[...truncated 380.45 KB...]
 10.1sec, 
org.apache.calcite.adapter.geode.rel.GeodeBookstoreTest > 
testInSetFilterWithNestedStringField()
 10.3sec, 
org.apache.calcite.adapter.geode.rel.GeodeAllDataTypesTest > 
testSqlWhereWithMultipleOrForLiteralFields()
  9.8sec, 
org.apache.calcite.adapter.geode.rel.GeodeZipsTest > 
testMaxRaw()
  9.8sec, 
org.apache.calcite.adapter.geode.rel.GeodeBookstoreTest > 
testAddMissingGroupByColumnToProjectedFields()
  9.9sec, 
org.apache.calcite.adapter.geode.rel.GeodeZipsTest > 
testWhereWithOrForNumericField()
  9.9sec, 
org.apache.calcite.adapter.geode.rel.GeodeZipsTest > 
testSelectLocItem()
  9.9sec, 
org.apache.calcite.adapter.geode.rel.GeodeBookstoreTest > 
testSortWithProjectionAndLimit()
 10.3sec, 
org.apache.calcite.adapter.geode.rel.GeodeBookstoreTest > 
testSqlSimple()
 10.5sec, 
org.apache.calcite.adapter.geode.rel.GeodeAllDataTypesTest > 
testSqlWhereWithMultipleOrForAllFields()
 10.1sec, 
org.apache.calcite.adapter.geode.rel.GeodeZipsTest > 
testWhereWithOrForNestedNumericField()
 10.4sec, 
org.apache.calcite.adapter.geode.rel.GeodeBookstoreTest > 
testFilterWithNestedField()
 10.6sec, 
org.apache.calcite.adapter.geode.rel.GeodeBookstoreTest > 
testWhereWithOr()
 11.2sec, 
org.apache.calcite.adapter.geode.rel.GeodeAllDataTypesTest > 
testSqlSingleDateWhereFilter()
 10.9sec, 
org.apache.calcite.adapter.geode.rel.GeodeAllDataTypesTest > 
testSqlSingleTimestampWhereFilter()
 11.6sec, 
org.apache.calcite.adapter.geode.rel.GeodeAllDataTypesTest > 
testSqlSingleTimeWhereFilter()
 11.4sec, 
org.apache.calcite.adapter.geode.rel.GeodeZipsTest > 
testWhereWithOrForLargeValueList()
 29.2sec,   12 completed,   0 failed,   0 skipped, 
org.apache.calcite.adapter.geode.rel.GeodeAllDataTypesTest
  2.1sec, 
org.apache.calcite.adapter.geode.rel.GeodeBookstoreTest > 
testMaxMinSumAvg()
 12.6sec, 
org.apache.calcite.adapter.geode.rel.GeodeZipsTest > 
testItemPredicate()
WARNING  30.3sec,   14 completed,   0 failed,   3 
skipped, org.apache.calcite.adapter.geode.rel.GeodeZipsTest
  2.6sec, 
org.apache.calcite.adapter.geode.rel.GeodeBookstoreTest > 
testMaxMinSumAvgInGroupBy()
  2.6sec, 
org.apache.calcite.adapter.geode.rel.GeodeBookstoreTest > 
testWhereWithOrAnd()
 30.9sec,   36 completed,   0 failed,   0 skipped, 
org.apache.calcite.adapter.geode.rel.GeodeBookstoreTest
WARNING  42.6sec,   62 completed,   0 failed,   3 
skipped, Gradle Test Run :geode:test

> Task :redis:test
docker[redis:2.8.19] 2023-04-21 09:31:18,012 
[docker-java-stream--1133810895] INFO  - Pulling image layers:  0 pending,  9 
downloaded,  8 extracted, (46 MB/46 MB)
docker[redis:2.8.19] 2023-04-21 09:31:19,857 
[docker-java-stream--1133810895] INFO  - Pulling image layers:  0 pending,  9 
downloaded,  9 extracted, (46 MB/46 MB)

> Task :testkit:test

FixtureTest > testSqlToRelFixtureNeedsDiffRepos() STANDARD_ERROR
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further 
details.
  0.5sec,1 completed,   0 failed,   0 skipped, 
org.apache.calcite.TestKtTest
  0.6sec,5 completed,   0 failed,   0 skipped, 
org.apache.calcite.util.TestUtilTest
  2.9sec, org.apache.calcite.test.FixtureTest > 
testValidatorFixture()
  7.0sec, org.apache.calcite.test.FixtureTest > 
testSqlToRelFixture()
  7.3sec, org.apache.calcite.test.FixtureTest > 
testRuleFixtureNeedsDiffRepos()
  7.7sec, org.apache.calcite.test.FixtureTest > 
testMetadata()
  8.1sec, org.apache.calcite.test.FixtureTest > 
testRuleFixture()
  9.4sec, org.apache.calcite.test.FixtureTest > 

Re: [DISCUSS] Disable JIRA worklog for GitHub PRs

2023-04-21 Thread Stamatis Zampetakis
Thanks everyone for the feedback. The change is now merged!

On Wed, Apr 19, 2023 at 4:59 PM Dan Zou  wrote:
>
> +1, it would reduce a lot of noise.
>
> Best,
> Dan Zou
>
>
>
>
>
> > 2023年4月19日 19:37,Benchao Li  写道:
> >
> > +1,
> >
> > One thing that may affect current workflow is sometimes I only watch the
> > Jira, and will get notified from the PR notification. If we are going to
> > disable it, I need to watch the PR too to get the notification for cases
> > that I'm interested in both the Jira discussion and PR comments. But that
> > won't be a big problem for me.
> >
> > Michael Mior  于2023年4月19日周三 18:43写道:
> >
> >> +1 from me as well
> >>
> >> On Wed, Apr 19, 2023, 04:19 Stamatis Zampetakis  wrote:
> >>
> >>> Hello,
> >>>
> >>> Everything that happens in a GitHub PR creates a worklog entry under
> >>> the respective JIRA ticket.
> >>> For every worklog entry we receive a notification from j...@apache.org
> >>> when we are watching an issue. The worklog entry and email
> >>> notification usually appear messy.
> >>>
> >>> Moreover, if we are watching the GitHub PR we are going to get a
> >>> notification from notificati...@github.com which has the same content
> >>> with the JIRA worklog entry and is much more readable.
> >>>
> >>> Finally, the PR notification is also going to
> >>> comm...@calcite.apache.org so those who are subscribed to that list
> >>> will get the same notification three times.
> >>>
> >>> Personally, I never read the JIRA worklog notifications and I largely
> >>> prefer those from notificati...@github.com.
> >>>
> >>> How do you feel about disabling the worklog entries in JIRA coming
> >>> from GitHub PRs?
> >>>
> >>> For archiving purposes, the notifications already go to commits@ so we
> >>> don't lose anything from disabling the worklog entries. On the
> >>> contrary, I find that this would reduce the noise and redundancy on
> >>> our inboxes.
> >>>
> >>> Concretely this is what I have in mind in terms of change:
> >>> https://github.com/apache/calcite/pull/3166
> >>>
> >>> Best,
> >>> Stamatis
> >>>
> >>
> >
> >
> > --
> >
> > Best,
> > Benchao Li
>


[jira] [Created] (CALCITE-5667) Unexpected result with aggregate inside subquery

2023-04-21 Thread Evgeny Stanilovsky (Jira)
Evgeny Stanilovsky created CALCITE-5667:
---

 Summary: Unexpected result with aggregate inside subquery
 Key: CALCITE-5667
 URL: https://issues.apache.org/jira/browse/CALCITE-5667
 Project: Calcite
  Issue Type: Bug
  Components: core
Affects Versions: 1.34.0
Reporter: Evgeny Stanilovsky


 
{noformat}
CREATE TABLE TBL1(ID INT PRIMARY KEY, VAL int);
insert into TBL1 values (1, 1), (2, 2);
select (select(sum(VAL))) from TBL1; <-- await 3 as a result
{noformat}
 

but obtain :

 
{noformat}
1
2
{noformat}
appropriate Quidem test for _blank.iq_
{noformat}
select (select(sum(I))) from bar;{noformat}
explain shows :
{noformat}
 EnumerableCalc(expr#0..2=[{inputs}], EXPR$0=[$t2])
   EnumerableCorrelate(correlation=[$cor0], joinType=[left], 
requiredColumns=[{0}])
     EnumerableTableScan(table=[[BLANK, BAR]])
     EnumerableAggregate(group=[{}], EXPR$0=[SUM($0)])
       EnumerableCalc(expr#0=[{inputs}], expr#1=[$cor0], expr#2=[$t1.I], 
$f0=[$t2])
         EnumerableValues(tuples=[[{ 0 }]]){noformat}
 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)