diff --git a/coral-common/src/main/java/com/linkedin/coral/common/CoralJavaTypeFactoryImpl.java b/coral-common/src/main/java/com/linkedin/coral/common/CoralJavaTypeFactoryImpl.java index a7d9acf6d..b3aee1ede 100644 --- a/coral-common/src/main/java/com/linkedin/coral/common/CoralJavaTypeFactoryImpl.java +++ b/coral-common/src/main/java/com/linkedin/coral/common/CoralJavaTypeFactoryImpl.java @@ -1,21 +1,25 @@ +/** + * Copyright 2023 LinkedIn Corporation. All rights reserved. + * Licensed under the BSD-2 Clause license. + * See LICENSE in the project root for license information. + */ package com.linkedin.coral.common; +import java.util.List; + import org.apache.calcite.jdbc.JavaTypeFactoryImpl; import org.apache.calcite.rel.type.RelDataType; import org.apache.calcite.rel.type.RelDataTypeSystem; import org.apache.calcite.rel.type.StructKind; -import java.util.List; public class CoralJavaTypeFactoryImpl extends JavaTypeFactoryImpl { - public CoralJavaTypeFactoryImpl(RelDataTypeSystem typeSystem) { - super(typeSystem); - } + public CoralJavaTypeFactoryImpl(RelDataTypeSystem typeSystem) { + super(typeSystem); + } - @Override - public RelDataType createStructType( - final List typeList, - final List fieldNameList) { - return createStructType(StructKind.PEEK_FIELDS, typeList, fieldNameList); - } + @Override + public RelDataType createStructType(final List typeList, final List fieldNameList) { + return createStructType(StructKind.PEEK_FIELDS_NO_EXPAND, typeList, fieldNameList); + } } diff --git a/coral-hive/src/test/java/com/linkedin/coral/hive/hive2rel/HiveTableTest.java b/coral-hive/src/test/java/com/linkedin/coral/hive/hive2rel/HiveTableTest.java index fb5bb9df3..8c26819f7 100644 --- a/coral-hive/src/test/java/com/linkedin/coral/hive/hive2rel/HiveTableTest.java +++ b/coral-hive/src/test/java/com/linkedin/coral/hive/hive2rel/HiveTableTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2017-2022 LinkedIn Corporation. All rights reserved. + * Copyright 2017-2023 LinkedIn Corporation. All rights reserved. * Licensed under the BSD-2 Clause license. * See LICENSE in the project root for license information. */ @@ -121,8 +121,8 @@ public void testTableWithUnionComplex() throws Exception { HiveToRelConverter converter = new HiveToRelConverter(mscAdapter); RelDataType rowType2 = converter.convertSql("SELECT coalesce_struct(foo) AS bar from nested_union").getRowType(); assertNotNull(rowType2); - expectedTypeString = "RecordType(" + "RecordType(" + "INTEGER tag_0, DOUBLE tag_1, " - + "RecordType(INTEGER a, RecordType(INTEGER tag_0, DOUBLE tag_1) b) tag_2) bar)"; + expectedTypeString = "RecordType(" + "RecordType:peek_no_expand(" + "INTEGER tag_0, DOUBLE tag_1, " + + "RecordType:peek_no_expand(INTEGER a, RecordType:peek_no_expand(INTEGER tag_0, DOUBLE tag_1) b) tag_2) bar)"; assertEquals(rowType2.toString(), expectedTypeString); } diff --git a/coral-hive/src/test/java/com/linkedin/coral/hive/hive2rel/HiveToRelConverterTest.java b/coral-hive/src/test/java/com/linkedin/coral/hive/hive2rel/HiveToRelConverterTest.java index 6ab45e7bc..d8f047777 100644 --- a/coral-hive/src/test/java/com/linkedin/coral/hive/hive2rel/HiveToRelConverterTest.java +++ b/coral-hive/src/test/java/com/linkedin/coral/hive/hive2rel/HiveToRelConverterTest.java @@ -15,7 +15,6 @@ import org.apache.calcite.plan.RelOptUtil; import org.apache.calcite.rel.RelNode; -import org.apache.calcite.runtime.CalciteContextException; import org.apache.calcite.sql.SqlNode; import org.apache.calcite.sql.type.ReturnTypes; import org.apache.calcite.sql.type.SqlTypeFamily; @@ -484,15 +483,6 @@ public void testStructFieldAccess() { } } - // Calcite supports PEEK_FIELDS to peek into struct fields - // That is not suitable for our usecase. This test is to ensure - // we don't inadvertently introduce that change - @Test(expectedExceptions = CalciteContextException.class) - public void testStructPeekDisallowed() { - final String sql = "SELECT name from complex"; - RelNode rel = toRel(sql); - } - @Test public void testStructReturnFieldAccess() { final String sql = "select named_struct('field_a', 10, 'field_b', 'abc').field_b"; diff --git a/coral-hive/src/test/java/com/linkedin/coral/hive/hive2rel/LateralViewTest.java b/coral-hive/src/test/java/com/linkedin/coral/hive/hive2rel/LateralViewTest.java index a8f3efb39..1e5d85cb6 100644 --- a/coral-hive/src/test/java/com/linkedin/coral/hive/hive2rel/LateralViewTest.java +++ b/coral-hive/src/test/java/com/linkedin/coral/hive/hive2rel/LateralViewTest.java @@ -1,5 +1,5 @@ /** - * Copyright 2018-2022 LinkedIn Corporation. All rights reserved. + * Copyright 2018-2023 LinkedIn Corporation. All rights reserved. * Licensed under the BSD-2 Clause license. * See LICENSE in the project root for license information. */ @@ -136,7 +136,7 @@ public void testLateralUDTF() { String expectedPlan = "LogicalProject(a=[$0], col1=[$4])\n" + " LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{0}])\n" + " LogicalTableScan(table=[[hive, test, tableone]])\n" - + " LogicalTableFunctionScan(invocation=[com.linkedin.coral.hive.hive2rel.CoralTestUDTF($cor0.a)], rowType=[RecordType(INTEGER col1)])\n"; + + " LogicalTableFunctionScan(invocation=[com.linkedin.coral.hive.hive2rel.CoralTestUDTF($cor0.a)], rowType=[RecordType:peek_no_expand(INTEGER col1)])\n"; assertEquals(RelOptUtil.toString(rel), expectedPlan); }