11/**
2- * Copyright 2017-2024 LinkedIn Corporation. All rights reserved.
2+ * Copyright 2017-2025 LinkedIn Corporation. All rights reserved.
33 * Licensed under the BSD-2 Clause license.
44 * See LICENSE in the project root for license information.
55 */
3030
3131import com .linkedin .coral .com .google .common .collect .ImmutableList ;
3232import com .linkedin .coral .common .HiveMetastoreClient ;
33+ import com .linkedin .coral .common .catalog .CoralCatalog ;
3334import com .linkedin .coral .common .functions .CoralSqlUnnestOperator ;
3435import com .linkedin .coral .common .functions .FunctionFieldReferenceOperator ;
3536import com .linkedin .coral .transformers .CoralRelToSqlNodeConverter ;
@@ -55,6 +56,7 @@ public class RelToTrinoConverter extends RelToSqlConverter {
5556 */
5657 private Map <String , Boolean > configs = new HashMap <>();
5758 private HiveMetastoreClient _hiveMetastoreClient ;
59+ private CoralCatalog _coralCatalog ;
5860
5961 /**
6062 * Creates a RelToTrinoConverter.
@@ -65,6 +67,12 @@ public RelToTrinoConverter(HiveMetastoreClient mscClient) {
6567 _hiveMetastoreClient = mscClient ;
6668 }
6769
70+ public RelToTrinoConverter (CoralCatalog coralCatalog ) {
71+ super (CoralRelToSqlNodeConverter .INSTANCE );
72+ _coralCatalog = coralCatalog ;
73+ ;
74+ }
75+
6876 /**
6977 * Creates a RelToTrinoConverter.
7078 * @param mscClient client interface used to interact with the Hive Metastore service.
@@ -84,9 +92,15 @@ public RelToTrinoConverter(HiveMetastoreClient mscClient, Map<String, Boolean> c
8492 */
8593 public String convert (RelNode relNode ) {
8694 SqlNode sqlNode = convertToSqlNode (relNode );
95+ SqlNode sqlNodeWithRelDataTypeDerivedConversions ;
8796
88- SqlNode sqlNodeWithRelDataTypeDerivedConversions =
89- sqlNode .accept (new DataTypeDerivedSqlCallConverter (_hiveMetastoreClient , sqlNode ));
97+ if (_coralCatalog != null ) {
98+ sqlNodeWithRelDataTypeDerivedConversions =
99+ sqlNode .accept (new DataTypeDerivedSqlCallConverter (_coralCatalog , sqlNode ));
100+ } else {
101+ sqlNodeWithRelDataTypeDerivedConversions =
102+ sqlNode .accept (new DataTypeDerivedSqlCallConverter (_hiveMetastoreClient , sqlNode ));
103+ }
90104
91105 SqlNode sqlNodeWithUDFOperatorConverted =
92106 sqlNodeWithRelDataTypeDerivedConversions .accept (new CoralToTrinoSqlCallConverter (configs ));
0 commit comments