-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce OrdinalReturnTypeInferenceV2 to infer RexCall's return type (…
…#481) * /OrdinalReturnTypeInferenceV2 to infer RexCall return type * add cast_nullability as an inbuilt function * spotless fix * coral-hive spotlesscheck * modify UDF name * coral-schema spotlessApply
- Loading branch information
Showing
7 changed files
with
131 additions
and
8 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
...rc/main/java/com/linkedin/coral/hive/hive2rel/functions/OrdinalReturnTypeInferenceV2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* 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.hive.hive2rel.functions; | ||
|
||
import org.apache.calcite.sql.type.OrdinalReturnTypeInference; | ||
|
||
|
||
/** | ||
* Custom implementation of {@link OrdinalReturnTypeInference} which allows inferring the return type | ||
* based on the ordinal of a given input argument and also exposes the ordinal. | ||
*/ | ||
public class OrdinalReturnTypeInferenceV2 extends OrdinalReturnTypeInference { | ||
private final int ordinal; | ||
|
||
public OrdinalReturnTypeInferenceV2(int ordinal) { | ||
super(ordinal); | ||
this.ordinal = ordinal; | ||
} | ||
|
||
public int getOrdinal() { | ||
return ordinal; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
coral-schema/src/test/resources/testLiGrootCastNullability-expected.avsc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"type" : "record", | ||
"name" : "basecomplexnonnullable", | ||
"namespace" : "coral.schema.avro.base.complex.nonnullable", | ||
"fields" : [ { | ||
"name" : "modCol", | ||
"type" : { | ||
"type" : "record", | ||
"name" : "Struct_col", | ||
"namespace" : "coral.schema.avro.base.complex.nonnullable.basecomplexnonnullable", | ||
"fields" : [ { | ||
"name" : "Bool_Field", | ||
"type" : "boolean" | ||
}, { | ||
"name" : "Int_Field", | ||
"type" : "int" | ||
}, { | ||
"name" : "Bigint_Field", | ||
"type" : "long" | ||
}, { | ||
"name" : "Float_Field", | ||
"type" : "float" | ||
}, { | ||
"name" : "Double_Field", | ||
"type" : "double" | ||
}, { | ||
"name" : "Date_String_Field", | ||
"type" : "string" | ||
}, { | ||
"name" : "String_Field", | ||
"type" : "string" | ||
}, { | ||
"name" : "Array_Col", | ||
"type" : { | ||
"type" : "array", | ||
"items" : { | ||
"type" : "record", | ||
"name" : "Struct_col", | ||
"namespace" : "coral.schema.avro.base.complex.nonnullable.basecomplexnonnullable.basecomplexnonnullable", | ||
"fields" : [ { | ||
"name" : "key", | ||
"type" : "string" | ||
}, { | ||
"name" : "value", | ||
"type" : "string" | ||
} ] | ||
} | ||
} | ||
}, { | ||
"name" : "Map_Col", | ||
"type" : { | ||
"type" : "map", | ||
"values" : "string" | ||
} | ||
} ] | ||
} | ||
} ] | ||
} |