Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ and implementing query rewrite algorithms for data governance and query optimiza
- Coral-Visualization [WIP]: Visualizes Coral SqlNode and RelNode trees and renders them to an output file.
- Coral-Service: Service that exposes REST APIs that allow users to interact with Coral (see [Coral-as-a-Service](#Coral-as-a-Service) for more details).

## Version Upgrades

This project adheres to semantic versioning, where the format x.y.z represents major, minor, and patch version upgrades. Consideration should be given to potential changes required when integrating different versions of this project.

**'y' Upgrade**

An 'y' upgrade represents a version change that introduces backward incompatibility by removal or modification of methods.

**'x' Upgrade**

An 'x' upgrade signifies a version change that introduces backward incompatibility by affecting the availability of classes.

Please carefully review the release notes and documentation accompanying each version upgrade to understand the specific changes and the recommended steps for migration.


## How to Build

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static String translateTrinoToSpark(String query) {

public static String translateHiveToTrino(String query) {
RelNode relNode = new HiveToRelConverter(hiveMetastoreClient).convertSql(query);
return new RelToTrinoConverter().convert(relNode);
return new RelToTrinoConverter(hiveMetastoreClient).convert(relNode);
}

public static String translateHiveToSpark(String query) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ public class HiveToTrinoConverter {
public static HiveToTrinoConverter create(HiveMetastoreClient mscClient) {
checkNotNull(mscClient);
HiveToRelConverter hiveToRelConverter = new HiveToRelConverter(mscClient);
RelToTrinoConverter relToTrinoConverter = new RelToTrinoConverter();
RelToTrinoConverter relToTrinoConverter = new RelToTrinoConverter(mscClient);
return new HiveToTrinoConverter(hiveToRelConverter, relToTrinoConverter);
}

public static HiveToTrinoConverter create(HiveMetastoreClient mscClient, Map<String, Boolean> configs) {
checkNotNull(mscClient);
checkNotNull(configs);
HiveToRelConverter hiveToRelConverter = new HiveToRelConverter(mscClient);
RelToTrinoConverter relToTrinoConverter = new RelToTrinoConverter(configs);
RelToTrinoConverter relToTrinoConverter = new RelToTrinoConverter(mscClient, configs);
return new HiveToTrinoConverter(hiveToRelConverter, relToTrinoConverter);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.calcite.sql.type.SqlTypeName;

import com.linkedin.coral.com.google.common.collect.ImmutableList;
import com.linkedin.coral.common.HiveMetastoreClient;
import com.linkedin.coral.common.functions.FunctionFieldReferenceOperator;
import com.linkedin.coral.hive.hive2rel.rel.HiveUncollect;
import com.linkedin.coral.trino.rel2trino.functions.TrinoArrayTransformFunction;
Expand Down Expand Up @@ -59,18 +60,27 @@ public class RelToTrinoConverter extends RelToSqlConverter {
* For uses outside LinkedIn, just ignore this configuration.
*/
private Map<String, Boolean> configs = new HashMap<>();
private HiveMetastoreClient _hiveMetastoreClient;

/**
* Creates a RelToTrinoConverter.
* @param mscClient client interface used to interact with the Hive Metastore service.
*/
public RelToTrinoConverter() {
public RelToTrinoConverter(HiveMetastoreClient mscClient) {
super(TrinoSqlDialect.INSTANCE);
_hiveMetastoreClient = mscClient;
}

public RelToTrinoConverter(Map<String, Boolean> configs) {
/**
* Creates a RelToTrinoConverter.
* @param mscClient client interface used to interact with the Hive Metastore service.
* @param configs configs
*/
public RelToTrinoConverter(HiveMetastoreClient mscClient, Map<String, Boolean> configs) {
super(TrinoSqlDialect.INSTANCE);
checkNotNull(configs);
this.configs = configs;
_hiveMetastoreClient = mscClient;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ public void testCastVarbinaryToChar() {

@Test
public void testRlikeTransformation() {
RelToTrinoConverter relToTrinoConverter = new RelToTrinoConverter();
RelToTrinoConverter relToTrinoConverter = TestUtils.getRelToTrinoConverter();

RelNode relNode = TestUtils.getHiveToRelConverter().convertSql("SELECT '1' NOT RLIKE '^1$'");
String targetSql = "SELECT NOT \"REGEXP_LIKE\"('1', '^1$')\n" + "FROM (VALUES (0)) AS \"t\" (\"ZERO\")";
Expand All @@ -778,7 +778,7 @@ public void testRlikeTransformation() {

@Test
public void testRegexpTransformation() {
RelToTrinoConverter relToTrinoConverter = new RelToTrinoConverter();
RelToTrinoConverter relToTrinoConverter = TestUtils.getRelToTrinoConverter();

RelNode relNode = TestUtils.getHiveToRelConverter().convertSql("SELECT '1' NOT REGEXP '^1$'");
String targetSql = "SELECT NOT \"REGEXP_LIKE\"('1', '^1$')\n" + "FROM (VALUES (0)) AS \"t\" (\"ZERO\")";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,11 @@ public static HiveToRelConverter getHiveToRelConverter() {
}

public static RelToTrinoConverter getRelToTrinoConverter() {
return new RelToTrinoConverter();
return new RelToTrinoConverter(hiveMetastoreClient);
}

public static RelToTrinoConverter getRelToTrinoConverter(Map<String, Boolean> configs) {
return new RelToTrinoConverter(configs);
return new RelToTrinoConverter(hiveMetastoreClient, configs);
}

public static void initializeTablesAndViews(HiveConf conf) throws HiveException, MetaException, IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static TrinoToRelConverter getTrinoToRelConverter() {
}

public static RelToTrinoConverter getRelToTrinoConverter() {
return new RelToTrinoConverter();
return new RelToTrinoConverter(hiveMetastoreClient);
}

public static void initializeViews(HiveConf conf) throws HiveException, MetaException, IOException {
Expand Down
2 changes: 1 addition & 1 deletion version.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Version of the produced binaries.
# The version is inferred by shipkit-auto-version Gradle plugin (https://github.com/shipkit/shipkit-auto-version)
version=2.0.*
version=2.1.*