RE: [DISCUSS] State of the project 2023

2023-10-23 Thread mbudiu
Hello all, Calcite is great! However, I think that there are several areas where the project could do better: - testing - documentation - legacy code cleanup (1) Testing: Most of my work in Calcite so far has been about testing. I have contributed the SqlLogicTest suite, which uncovers many

RE: ClassCastException: class java.lang.Long cannot be cast to class java.lang.Float

2023-10-20 Thread mbudiu
This doe look like a bug in Avatica, indeed. Maybe you can file an issue on the JIRA. https://issues.apache.org/jira/projects/CALCITE/issues/CALCITE-5990?filter=a llopenissues You should provide enough instructions to reproduce this bug. Mihai -Original Message- From: Egor Ryashin Sent:

RE: is there a way to skip validation steps...

2023-10-19 Thread mbudiu
One of the main differences between SqlNode and RelNode is that RelNode can only represent valid programs. This is ensured by the validator. Most, if not all, optimizations rely on the program being a legal program in order to manipulate it. The validator also adds additional information to your

RE: Question about bitwise right operator

2023-10-12 Thread mbudiu
This is a notorious problem in C++-like languages. There are possible workarounds, depending on the parser generator you are using. In the P4 compiler, which does parsing using flex and bison, we essentially never parse ">>" as a token [1], but we reconstruct it from two adjacent ">" when used

RE: [DISCUSS] Towards Calcite 1.36.0

2023-10-08 Thread mbudiu
I will take care of https://issues.apache.org/jira/browse/CALCITE-5990 However, it is the first time I notice this issue, I wonder whether I missed some notification. Mihai -Original Message- From: Benchao Li Sent: Sunday, October 8, 2023 12:01 AM To: dev@calcite.apache.org Cc:

RE: SQL Parsing

2023-10-02 Thread mbudiu
Maybe I will write a blog post about this (I couldn't find documentation about this with a web search), but for now this is a short summary. Hopefully nothing I say here is wrong, this is relatively new stuff for me too. Calcite uses a two-step code generation process to create the parser: -

RE: CALCITE-5678/CALCITE-5957: Datetime literal validation

2023-09-29 Thread mbudiu
While I am not directly answering this question, I want to point out that other databases have very flexible formats. Here is an excerpt from Postgres: https://www.postgresql.org/docs/current/datatype-datetime.html Example Description 1999-01-08 ISO 8601; January 8 in any mode

Running CI Druid tests locally

2023-09-26 Thread mbudiu
Hello, I submitted a PR https://github.com/apache/calcite/pull/3435 which passes all tests locally, but fails the Druid tests in CI: https://github.com/apache/calcite/actions/runs/6257240352/job/16989292034?pr =3435 Does anyone know what I have to do to reproduce these locally? Thank you,

RE: RelToSqlConverter doesn't work on UNNEST?

2023-09-22 Thread mbudiu
I can't answer to this particular question, but I have been working on a Calcite test fixture (a tool which helps run many tests) for RelToSqlConverter and I found tens of bugs, which I haven't had yet time to file as issues. So it's very possible that this is a genuine bug. Mihai

RE: TIMESTAMPDIFF semantics

2023-09-06 Thread mbudiu
The following issues discuss the semantics of TIMESTAMPDIFF: https://issues.apache.org/jira/browse/CALCITE-1827, https://issues.apache.org/jira/browse/CALCITE-3529, https://issues.apache.org/jira/browse/CALCITE-1124. They all mention MySQL as a reference for this function. This would suggest that

TIMESTAMPDIFF semantics

2023-09-06 Thread mbudiu
I am looking at the TIMESTAMPDIFF function and every SQL dialect seems to have a slightly different definition, e.g.: Databricks: https://docs.databricks.com/en/sql/language-manual/functions/timestampdiff.h tml seems to round after computing the result: One month is

TimeString

2023-08-10 Thread mbudiu
Why does Calcite support arbitrary precision time-strings and yet makes it practically impossible to extract anything but milliseconds? Mihai

RE: [Discussion] Split function has some wrong and strange behaviors

2023-08-08 Thread mbudiu
mbudiu, thanks for your patience. Yes, a[x] interpret as a[OFFSET(x)] for BigQuery. I tried this, and it is okay too. On Wed, Aug 9, 2023 at 02:48 wrote: > This has nothing to do with the "Split" function. It is all about > indexing in arrays. > > The list of Dialect-specifi

RE: [Discussion] Split function has some wrong and strange behaviors

2023-08-08 Thread mbudiu
write a[x] and it should be interpreted as a[OFFSET (x)] when using BigQuery? Mihai -Original Message- From: P.F. ZHAN Sent: Tuesday, August 08, 2023 11:37 AM To: dev@calcite.apache.org Subject: Re: [Discussion] Split function has some wrong and strange behaviors Hi, mbudiu. f.check

RE: [Discussion] Split function has some wrong and strange behaviors

2023-08-08 Thread mbudiu
calcite.rel.rel2sql.RelToSqlConverterTest#testIndexWithoutO > peratorBigQuery > > > I also checked the BigQuery doc which only mentions these standard > usages in our test case of *testIndexOperatorsBigQuery*, but in fact > when we use SQL like > > > select split('aaa-bbb

RE: [Discussion] Split function has some wrong and strange behaviors

2023-08-08 Thread mbudiu
8, 2023 at 10:31 AM P.F. ZHAN mailto:dethr...@gmail.com> > wrote: > Thank you mbudiu, Ran Tao and Lake Shen. > > I have tried your suggestions and debugged the code, this kind of sql > seems not support > >> select split('aaa-bbb-ccc', '-')[1] >> > > I hav

RE: [Discussion] Split function has some wrong and strange behaviors

2023-08-08 Thread mbudiu
c', '-')[ offset(0)] Maybe Calcite should support this kind of usage rather than treat it as a limitation. On Tue, Aug 8, 2023 at 10:31 AM P.F. ZHAN wrote: > Thank you mbudiu, Ran Tao and Lake Shen. > > I have tried your suggestions and debugged the code, this kind of sql >

Extending SqlColumnDeclaration

2023-08-07 Thread mbudiu
I notice that SqlColumnDeclaration has a non-public constructor, which makes it impossible to extend from a different package. Is this design intentional or is it a bug? (There are some good reasons for extending this class. For example, a comment on the class says "FOREIGN KEY when we

RE: [Discussion] Split function has some wrong and strange behaviors

2023-08-07 Thread mbudiu
See also this thread: https://issues.apache.org/jira/browse/CALCITE-5760 You can run CalciteSqlOperatorTest instead. If you want to quickly debug only this test in the IDE you can copy-paste this test into the CalciteSqlOperatorTest class and run it from there, then delete it when you are done.

RE: [DISCUSS] Increase the default maximum precision and scale of the number type

2023-08-07 Thread mbudiu
Calcite gives you hooks to change these limits. For example: public static final RelDataTypeSystem TYPE_SYSTEM = new RelDataTypeSystemImpl() { @Override public int getMaxNumericPrecision() { return MAX_PRECISION; } @Override public int

RE: DECIMAL(2, 3) meaning

2023-08-06 Thread mbudiu
I found this documentation for Oracle DECIMAL data type: https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/Data-Types.html#GUID-75209AF6-476D-4C44-A5DC-5FA70D701B78, which explains what a SCALE > PRECISION should mean. > Scale can be greater than precision, most commonly when

RE: DECIMAL(2, 3) meaning

2023-08-04 Thread mbudiu
I have added this test to SqlOperatorTest: f.checkScalar("cast(0.012 as DECIMAL(2, 5))", new BigDecimal("0.012"), "DECIMAL(2, 5) NOT NULL"); and it has passed. That's why I am asking. It should fail, but it doesn't. Mihai -Original Message- From: stanilovsky evgeny Sent:

DECIMAL(2, 3) meaning

2023-08-03 Thread mbudiu
Hello, I notice that Calcite happily accepts decimal type specifications where the scale is greater than the precision. There are quite a few tests with such types. What is the meaning of such types? The SQL 92 standard has this statement on page 109: 15)The of an shall not be

Creating user-defined functions dynamically

2023-08-01 Thread mbudiu
Hello all, I have a question about user-defined functions. I see that one can extend Calcite by adding new functions to various libraries. My question is whether there exists a mechanism to add such functions *dynamically*, without changing the Calcite code. This would allow users to write

RE: Empty array literal

2023-08-01 Thread mbudiu
ambiguity in the grammar. Not having literals for empty arrays is like having numbers without a zero literal. Mihai -Original Message- From: Ran Tao Sent: Tuesday, August 01, 2023 5:04 AM To: dev@calcite.apache.org Subject: Re: Empty array literal Hi, mbudiu. thanks for creating

Empty array literal

2023-07-31 Thread mbudiu
Hello, It looks to me like the Calcite grammar does not accept empty array literals "ARRAY[]". This sounds like a serious omission. Is there a fundamental reason why this isn't in the grammar? If there isn't, I can file an issue for it. I can see a workaround using the Spark "ARRAY()"

On Postgres compatibility (WAS: Easier and more comprehensive testing)

2023-07-29 Thread mbudiu
Mihai -Original Message- From: LakeShen Sent: Friday, July 28, 2023 7:04 PM To: dev@calcite.apache.org Subject: Re: Easier and more comprehensive testing Hi mbudiu,thank you for bringing SqlLogicTest to calcite. Now we're working on an optimizer based on Calcite that supports Postgresql se

RE: Easier and more comprehensive testing

2023-07-28 Thread mbudiu
The correct link is https://github.com/feldera/dbsp/tree/main/sql-to-dbsp-compiler, but it's not particularly important, I apologize for the broken one. I appreciate you pointing out the Sql Logic Test project, I wrote that code too. But these two projects are almost entirely disjoint. SLT

Easier and more comprehensive testing

2023-07-27 Thread mbudiu
Hello, I am working to test our calcite-based compiler (https://github.com/feldera/dbsp/sql-to-dbsp-compiler), and since I am lazy I am borrowing tests from other open-source test suites, like Postgres. I am finding bugs in Calcite with a relatively high frequency, as you may have noticed if

Type inference for CASE expressions

2023-07-18 Thread mbudiu
Hello, I have a question about the type inference for case expressions. Consider this query from the Postgres tests: https://github.com/postgres/postgres/blob/137b131d6fbd29b4acf740aba3f74220fa ef2678/src/test/regress/expected/case.out#L136 SELECT i AS "Value", CASE WHEN (i < 0) THEN

RE: Re: Calcite for Lineage

2023-07-07 Thread mbudiu
Which parser are you using, the server (DDL) or Babel? I think DATEADD exists only in Babel. To solve this problem in our project we have combined both parsers into one, so now we can parse Babel + DDL. https://github.com/feldera/dbsp/pull/276 Mihai -Original Message- From: Nathaniel

RE: Developing problems with Calcite - Need help

2023-07-01 Thread mbudiu
Calcite is extremely flexible, you can assemble an optimizer manually, to do exactly what you want. Here is our example:

RE: Concatenating CHAR(N) and VARCHAR strings

2023-06-30 Thread mbudiu
Actually Postgres documents this behavior: https://www.postgresql.org/docs/15/functions-string.html text || anynonarray → text anynonarray || text → text Converts the non-string input to text, then concatenates the two strings. (The non-string input cannot be of an array type, because that

Concatenating CHAR(N) and VARCHAR strings

2023-06-29 Thread mbudiu
Hello, What happens when you concatenate a CHAR(N) and a VARCHAR value? Calcite seems to insert no casts before concatenation, so the trailing spaces for the CHAR(N) value are preserved. However, Postgres has the following test:

RE: Calcite for Lineage

2023-06-23 Thread mbudiu
>From my experience the Babel parser does NOT include DDL - at least not in the >released versions. Mihai -Original Message- From: Askar Bozcan Sent: Friday, June 23, 2023 1:14 AM To: dev@calcite.apache.org Subject: Re: Calcite for Lineage Hey Nathaniel, To parse DDL statements, you

VARIANT and JSON data types

2023-06-21 Thread mbudiu
Hello, I have a question about Calcite and fancier data types. It looks like Calcite JSON operations are really implemented by treating JSON as a string. I expect that this is expensive, since the string needs to be parsed and serialized back for every operation. Snowflake uses VARIANT

RE: Implementing EXPLODE operator

2023-06-03 Thread mbudiu
This seems to be the same as UNNEST WITH ORDINALITY, in Calcite since 2016. https://issues.apache.org/jira/browse/CALCITE-854 Mihai -Original Message- From: Soumyadeep Mukhopadhyay Sent: Saturday, June 03, 2023 10:42 AM To: dev@calcite.apache.org Subject: Re: Implementing EXPLODE

RE: Algebraic optimizations rule

2023-06-02 Thread mbudiu
at the simplification code to see whether it handles such cases. Thank you, Mihai -Original Message- From: Jiajun Xie Sent: Friday, June 02, 2023 7:08 PM To: dev@calcite.apache.org Subject: Re: Algebraic optimizations rule Hello, mbudiu: Based on my experience, constant folding can occur in two

Algebraic optimizations rule

2023-06-02 Thread mbudiu
Hello, I was looking for rules that apply algebraic optimizations to RexNode expressions, such as 0 + x = x, but I couldn't find any. Is there such a rule? Mihai