Skip to content

Commit

Permalink
Bump Coral to 1.0.120
Browse files Browse the repository at this point in the history
It also adds test for CAST(timestamp AS DECIMAL()); which apparently is
not working great.
  • Loading branch information
losipiuk committed Oct 12, 2021
1 parent 6c58b76 commit c7531ef
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<dep.errorprone.version>2.9.0</dep.errorprone.version>
<dep.testcontainers.version>1.16.0</dep.testcontainers.version>
<dep.docker-java.version>3.2.11</dep.docker-java.version>
<dep.coral.version>1.0.89</dep.coral.version>
<dep.coral.version>1.0.120</dep.coral.version>
<dep.confluent.version>5.5.2</dep.confluent.version>
<!-- TODO: update after moving to Airbase 112 -->
<dep.jackson.version>2.12.3</dep.jackson.version>
Expand Down Expand Up @@ -1046,7 +1046,7 @@
<dependency>
<groupId>com.linkedin.calcite</groupId>
<artifactId>calcite-core</artifactId>
<version>1.21.0.150</version>
<version>1.21.0.151</version>
<classifier>shaded</classifier>
<exclusions>
<exclusion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.assertj.core.api.Assertions;
import org.testng.annotations.Test;

import java.math.BigDecimal;

import static io.trino.tempto.assertions.QueryAssert.Row.row;
import static io.trino.tempto.assertions.QueryAssert.assertThat;
import static io.trino.tempto.query.QueryExecutor.query;
Expand Down Expand Up @@ -390,4 +392,30 @@ private boolean isObsoleteFromUtcTimestampSemantics()
// together with change of timestamp semantics at version 3.1.
return getHiveVersionMajor() < 3 || (getHiveVersionMajor() == 3 && getHiveVersionMinor() < 1);
}

@Test(groups = HIVE_VIEWS)
public void testCastTimestampAsDecimal()
{
onHive().executeQuery("DROP TABLE IF EXISTS cast_timestamp_as_decimal");
onHive().executeQuery("CREATE TABLE cast_timestamp_as_decimal (a_timestamp TIMESTAMP)");
onHive().executeQuery("INSERT INTO cast_timestamp_as_decimal VALUES ('1990-01-02 12:13:14.123456789')");
onHive().executeQuery("DROP VIEW IF EXISTS cast_timestamp_as_decimal_view");
onHive().executeQuery("CREATE VIEW cast_timestamp_as_decimal_view AS SELECT CAST(a_timestamp as DECIMAL(10,0)) a_cast_timestamp FROM cast_timestamp_as_decimal");

String testQuery = "SELECT * FROM cast_timestamp_as_decimal_view";
if (getHiveVersionMajor() > 3 || (getHiveVersionMajor() == 3 && getHiveVersionMinor() >= 1)) {
assertViewQuery(
testQuery,
queryAssert -> queryAssert.containsOnly(row(new BigDecimal("631282394"))));
}
else {
// For Hive versions older than 3.1 semantics of cast timestamp to decimal is different and it takes into account timezone Hive VM uses.
// We cannot replicate the behaviour in Trino, hence test only documents different expected results.
assertThat(onTrino().executeQuery(testQuery)).containsOnly(row(new BigDecimal("631282394")));
assertThat(onHive().executeQuery(testQuery)).containsOnly(row(new BigDecimal("631261694")));
}

onHive().executeQuery("DROP VIEW cast_timestamp_as_decimal_view");
onHive().executeQuery("DROP TABLE cast_timestamp_as_decimal");
}
}

0 comments on commit c7531ef

Please sign in to comment.