forked from trinodb/trino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change implements support for path extraction SerDe Properties. It uses the same ion-java-path-extraction library the Ion Hive SerDe does. Unlike the Hive SerDe, this ensures that the "strict" and more performant path extraction implementation is used. I chose to use the path-extraction in the absence of any defined path extractors. When a path extractor is defined, you have to define all columns as extractions. With the strict implementation, the field lookup is effectively the same as the Decoder here. So given that I would rather cut modality unless there's a really compelling reason.
- Loading branch information
1 parent
5e4dde0
commit bba2adc
Showing
9 changed files
with
246 additions
and
71 deletions.
There are no files selected for viewing
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
50 changes: 50 additions & 0 deletions
50
lib/trino-hive-formats/src/main/java/io/trino/hive/formats/ion/IonDecoderConfig.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,50 @@ | ||
/* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.trino.hive.formats.ion; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Captures the SerDe properties that affect decoding. | ||
* | ||
* @param pathExtractors Map of column name => ion paths | ||
* for each entry in the map, the value bound to the column will be the result | ||
* of extracting the given search path. | ||
* @param strictTyping whether the path extractions should enforce type expectations. | ||
* this only affects type checking of path extractions; any value decoded into | ||
* a trino column will be correctly typed or coerced for that column. | ||
* @param caseSensitive whether field name matching should be case-sensitive or not. | ||
*/ | ||
public record IonDecoderConfig(Map<String, String> pathExtractors, Boolean strictTyping, Boolean caseSensitive) | ||
{ | ||
static IonDecoderConfig defaultConfig() | ||
{ | ||
return new IonDecoderConfig(Map.of(), false, false); | ||
} | ||
|
||
IonDecoderConfig withStrictTyping() | ||
{ | ||
return new IonDecoderConfig(pathExtractors, true, caseSensitive); | ||
} | ||
|
||
IonDecoderConfig withCaseSensitive() | ||
{ | ||
return new IonDecoderConfig(pathExtractors, strictTyping, true); | ||
} | ||
|
||
IonDecoderConfig withPathExtractors(Map<String, String> pathExtractors) | ||
{ | ||
return new IonDecoderConfig(pathExtractors, strictTyping, caseSensitive); | ||
} | ||
} |
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
Oops, something went wrong.