Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug fix] fix hive partition cannot overwrite #212

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class InputOutputFormat {
}

public static OutputFormat <Row> createOutputFormat(
Catalog catalog, DynamicTableFactory.Context context, Map <String, String> partitions) {
Catalog catalog, DynamicTableFactory.Context context, Map <String, String> partitions, Boolean overwriteSink) {

if (!(catalog instanceof HiveCatalog)) {
throw new RuntimeException("Catalog should be hive catalog.");
Expand All @@ -72,6 +72,8 @@ public static OutputFormat <Row> createOutputFormat(
hiveTableSink.applyStaticPartition(partitions);
}

hiveTableSink.applyOverwrite(overwriteSink);

return hiveTableSink.getOutputFormat();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,7 @@ public boolean isTemporary() {
return factory.doAsThrowRuntime(() -> {

String partitionSpec = params.get(HiveCatalogParams.PARTITION);
boolean overwriteSink = params.get(HiveCatalogParams.OVERWRITE_SINK);

Map <String, String> partitions = null;
if (!StringUtils.isNullOrWhitespaceOnly(partitionSpec)) {
Expand All @@ -844,10 +845,10 @@ public boolean isTemporary() {
true, Thread.currentThread().getContextClassLoader()
);

Method method = inputOutputFormat.getMethod("createOutputFormat", Catalog.class, DynamicTableFactory.Context.class, Map.class);
Method method = inputOutputFormat.getMethod("createOutputFormat", Catalog.class, DynamicTableFactory.Context.class, Map.class, Boolean.class);

OutputFormat<Row> internalRet =
(OutputFormat <Row>) method.invoke(null, catalog, context, partitions);
(OutputFormat <Row>) method.invoke(null, catalog, context, partitions, overwriteSink);

return new RichOutputFormatWithClassLoader(factory, internalRet);
});
Expand Down