sdk2 commented on code in PR #69404:
URL: https://github.com/apache/doris/pull/69404#discussion_r4808610716
##########
fe/fe-connector/fe-connector-hive/src/main/java/org/apache/doris/connector/hive/HiveWritePlanProvider.java:
##########
@@ -351,6 +359,60 @@ private List<THivePartition>
buildExistingPartitions(HmsTableInfo table) {
return partitions;
}
+ private static Optional<String> fullyStaticPartitionName(HmsTableInfo
table, ConnectorWriteHandle handle) {
+ // Typed partition text can differ between FE literals and BE
directory formatting (e.g. BOOLEAN
+ // true versus 1). Narrow only string partitions, whose cast values
are the bytes BE will write.
+ for (ConnectorColumn column : table.getPartitionKeys()) {
+ String type = column.getType().getTypeName();
+ if (!"STRING".equalsIgnoreCase(type) &&
!"VARCHAR".equalsIgnoreCase(type)
+ && !"CHAR".equalsIgnoreCase(type)) {
+ return Optional.empty();
+ }
+ }
+ // Decide completeness from the literal spec BEFORE asking the handle
to cast it: a partially specified
+ // write can carry a literal whose FE cast fails even though another
partition key is dynamic and the
+ // full listing would be used. A missing or SQL NULL key is not a
fully static write.
+ Map<String, String> literalSpec = new
TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ literalSpec.putAll(handle.getStaticPartitionSpec());
+ Set<String> nullKeys = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
+ nullKeys.addAll(handle.getStaticPartitionNullKeys());
+ for (ConnectorColumn column : table.getPartitionKeys()) {
+ if (literalSpec.get(column.getName()) == null ||
nullKeys.contains(column.getName())) {
+ return Optional.empty();
+ }
+ }
+ // The cast is only for the lookup optimization. If the FE cannot
evaluate it, keep the full
+ // listing and leave the row value to BE, as the existing row path
does.
+ Map<String, String> castValues;
+ try {
+ castValues = handle.getCastStaticPartitionSpec();
Review Comment:
Done: the singleton lookup now narrows only when every captured static
partition value is a non-NULL string literal.
`ConnectorWriteHandle.hasOnlyStringStaticPartitionLiterals()` (default false)
carries that fact from `PluginDrivenInsertCommandContext` through
`PluginDrivenTableSink`, so `1e3` keeps the full listing while a quoted
`'1000'` still uses the target lookup.
Added provider tests for the numeric and numeric-looking-string cases, a
`'1000'` vs `1e3` binding test, and an `INSERT OVERWRITE ...
PARTITION(ts_date=1e3)` regression with `debug_skip_fold_constant=true`. Local
tests: HiveWritePlanProviderTest 48/48, CachingHmsClientTest 51/51,
PluginDrivenTableSinkBindingTest 10/10, ConnectorPluginSurfaceTest 2/2.
Because this adds a method to the frozen connector plugin surface,
`connector.plugin.api.version` moves 43.0 -> 44.0 and
`connector-plugin-surface.txt` is updated in the same commit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]