Skip to content

Commit

Permalink
IGNITE-22755 Sql. Bump calcite version to 1.38 (apache#4837)
Browse files Browse the repository at this point in the history
  • Loading branch information
zstan authored Dec 11, 2024
1 parent 23119a2 commit 7a2e161
Show file tree
Hide file tree
Showing 34 changed files with 2,405 additions and 1,441 deletions.
2 changes: 2 additions & 0 deletions check-rules/pmd-rules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,6 @@

<!-- exclusions -->
<exclude-pattern>.*/src/main/java/com/facebook/presto/.*</exclude-pattern>
<exclude-pattern>.*/sql/engine/exec/exp/RexImpTable\.java</exclude-pattern>
<exclude-pattern>.*/sql/engine/exec/exp/RexToLixTranslator\.java</exclude-pattern>
</ruleset>
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ hamcrestOptional = "2.0.0"
hamcrestPath = "1.0.1"
hamcrestJson = "0.3"
scalecube = "2.6.15"
calcite = "1.37.0"
calcite = "1.38.0"
value = "2.10.1"
janino = "3.1.12"
jsonpath = "2.9.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ private static Stream<Arguments> supportedTypesTransitions() {
arguments.add(Arguments.of("SMALLINT", Short.MAX_VALUE, ColumnType.INT32, "INT", Integer.MAX_VALUE));
arguments.add(Arguments.of("INT", Integer.MAX_VALUE, ColumnType.INT64, "BIGINT", Long.MAX_VALUE));
arguments.add(Arguments.of("FLOAT", Float.MAX_VALUE, ColumnType.DOUBLE, "DOUBLE", Double.MAX_VALUE));
arguments.add(Arguments.of("FLOAT", Float.MIN_VALUE, ColumnType.DOUBLE, "DOUBLE", Double.MIN_VALUE));
arguments.add(Arguments.of("VARCHAR(10)", "'" + "c".repeat(10) + "'", ColumnType.STRING,
"VARCHAR(20)", "'" + "c".repeat(20) + "'"));
arguments.add(Arguments.of("VARBINARY(1)", "x'01'", ColumnType.BYTE_ARRAY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@
*/
@WithSystemProperty(key = "IMPLICIT_PK_ENABLED", value = "true")
public class ItCastToBigintTest extends BaseSqlIntegrationTest {
@Override
protected int initialNodes() {
return 1;
}

@BeforeAll
static void createTable() {
sql("CREATE TABLE test (val BIGINT)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@
*/
@WithSystemProperty(key = "IMPLICIT_PK_ENABLED", value = "true")
public class ItCastToIntTest extends BaseSqlIntegrationTest {
@Override
protected int initialNodes() {
return 1;
}

@BeforeAll
static void createTable() {
sql("CREATE TABLE test (val INTEGER)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@
*/
@WithSystemProperty(key = "IMPLICIT_PK_ENABLED", value = "true")
public class ItCastToSmallintTest extends BaseSqlIntegrationTest {
@Override
protected int initialNodes() {
return 1;
}

@BeforeAll
static void createTable() {
sql("CREATE TABLE test (val SMALLINT)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@
*/
@WithSystemProperty(key = "IMPLICIT_PK_ENABLED", value = "true")
public class ItCastToTinyintTest extends BaseSqlIntegrationTest {
@Override
protected int initialNodes() {
return 1;
}

@BeforeAll
static void createTable() {
sql("CREATE TABLE test (val TINYINT)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
*/
@WithSystemProperty(key = "IMPLICIT_PK_ENABLED", value = "true")
public class ItCastToTsWithLocalTimeZoneTest extends BaseSqlIntegrationTest {
@Override
protected int initialNodes() {
return 1;
}

@BeforeAll
static void createTable() {
sql("CREATE TABLE test (val TIMESTAMP WITH LOCAL TIME ZONE)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ endfor
query T
SELECT CAST(100.1::REAL AS DOUBLE);
----
100.1
100.0999984741211

query T
SELECT CAST(100.1::FLOAT AS DOUBLE);
----
100.1
100.0999984741211

statement error: For input string: "e1"
SELECT CAST('e1' AS DOUBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ SELECT 1::BIGINT::VARCHAR, 1244295295289253::BIGINT::VARCHAR, (-2000000111551166
query TTT
SELECT 2::FLOAT::VARCHAR, 0.5::FLOAT::VARCHAR, (-128.5)::FLOAT::VARCHAR
----
2
2.0
0.5
-128.5

query TTT
SELECT 2::DOUBLE::VARCHAR, 0.5::DOUBLE::VARCHAR, (-128.5)::DOUBLE::VARCHAR
----
2
2.0
0.5
-128.5

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@ select * from t1 join t2 on (i=j), t3 join t4 on (k=l) order by 1, 2, 3, 4;
1 1 2 2
1 1 3 3

statement error
query IIII rowsort
select * from t1 join t2 on (i=j), t3 join t4 on (i+k=j+l)
----
1 1 2 2
1 1 3 3
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ statement error: BIGINT out of range
SELECT -9223372036854775808/-1

statement error: BIGINT out of range
SELECT 9223372036854775808
SELECT 9223372036854775808::BIGINT

statement error: BIGINT out of range
SELECT 9223372036854775807 + 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ public Iterable<RowT> values(List<RexLiteral> values, RelDataType rowType) {
RelDataType dataType = literal.getType();

if (SqlTypeUtil.isNumeric(dataType)) {
BigDecimal value = (BigDecimal) literal.getValue();
Number value = (Number) literal.getValue();
if (value == null) {
return null;
}
Expand Down Expand Up @@ -1223,7 +1223,7 @@ public RexNode visitCorrelVariable(RexCorrelVariable variable) {
}
}

private static Object convertNumericLiteral(RelDataType dataType, BigDecimal value, Class<?> type) {
private static Object convertNumericLiteral(RelDataType dataType, Number value, Class<?> type) {
Primitive primitive = Primitive.ofBoxOr(type);
assert primitive != null || type == BigDecimal.class : "Neither primitive nor BigDecimal: " + type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,30 @@ public static BigDecimal toBigDecimal(Number value, int precision, int scale) {
}
}

// LN, LOG, LOG10, LOG2

/** SQL {@code LOG(number, number2)} function applied to double values. */
public static double log(double d0, double d1) {
return Math.log(d0) / Math.log(d1);
}

/** SQL {@code LOG(number, number2)} function applied to
* double and BigDecimal values. */
public static double log(double d0, BigDecimal d1) {
return Math.log(d0) / Math.log(d1.doubleValue());
}

/** SQL {@code LOG(number, number2)} function applied to
* BigDecimal and double values. */
public static double log(BigDecimal d0, double d1) {
return Math.log(d0.doubleValue()) / Math.log(d1);
}

/** SQL {@code LOG(number, number2)} function applied to double values. */
public static double log(BigDecimal d0, BigDecimal d1) {
return Math.log(d0.doubleValue()) / Math.log(d1.doubleValue());
}

private static BigDecimal processValueWithIntegralPart(Number value, int precision, int scale) {
BigDecimal dec = convertToBigDecimal(value);

Expand Down
Loading

0 comments on commit 7a2e161

Please sign in to comment.