mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(athena): run Hive DDL against the Glue catalog (#8411)
Athena runs Hive DDL against the Glue Data Catalog, but Floci sent every statement other than CREATE DATABASE to DuckDB: CREATE EXTERNAL TABLE, ALTER TABLE ADD PARTITION, MSCK REPAIR TABLE and SHOW PARTITIONS failed to parse, and DROP TABLE succeeded without touching Glue. AthenaHiveDdl parses CREATE EXTERNAL TABLE (columns, PARTITIONED BY, CLUSTERED BY, ROW FORMAT DELIMITED or SERDE, STORED AS, LOCATION, TBLPROPERTIES, with the SerDe parameters and input/output formats Hive stores), DROP TABLE, ALTER TABLE ADD/DROP PARTITION, MSCK REPAIR TABLE and SHOW PARTITIONS; AthenaHiveDdlExecutor applies them to Glue as Athena does: DROP TABLE keeps the data, MSCK only adds Hive-style partitions, IF [NOT] EXISTS turns duplicates and misses into no-ops, and SHOW PARTITIONS writes its rows as the query's result. A CREATE TABLE without EXTERNAL fails unless it is Iceberg or CREATE TABLE AS, which still go to the query engine. Mock mode keeps DDL result rows.
This commit is contained in:
1 parent
7a682dcd00
commit
cc9b5bfee1
7 files changed
+1429
-2
No files matched your search
@@ -0,0 +1,575 @@
|
||||
package io.floci.aws.services.athena;
|
||||
|
||||
import io.floci.aws.core.common.AwsException;
|
||||
import io.floci.aws.services.glue.model.Column;
|
||||
import io.floci.aws.services.glue.model.StorageDescriptor;
|
||||
import io.floci.aws.services.glue.model.Table;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Parses the Hive DDL statements Athena runs against the Glue Data Catalog rather than against
|
||||
* data: {@code CREATE EXTERNAL TABLE}, {@code DROP TABLE}, {@code ALTER TABLE ... ADD|DROP
|
||||
* PARTITION}, {@code MSCK REPAIR TABLE} and {@code SHOW PARTITIONS}. {@link #parse} answers null
|
||||
* for every other statement, an Iceberg {@code CREATE TABLE} and {@code CREATE TABLE AS} included,
|
||||
* so those keep going to the query engine.
|
||||
*
|
||||
* <p>Names are lower-cased, as Athena stores them in Glue. String literals take Hive's backslash
|
||||
* escapes, so {@code FIELDS TERMINATED BY '\t'} stores a tab.
|
||||
*/
|
||||
final class AthenaHiveDdl {
|
||||
|
||||
sealed interface Statement permits CreateTable, DropTable, AddPartitions, DropPartitions, RepairTable,
|
||||
ShowPartitions {
|
||||
TableRef ref();
|
||||
}
|
||||
|
||||
/** A table name; {@code database} is null when the statement leaves it to the query context. */
|
||||
record TableRef(String database, String table) {
|
||||
}
|
||||
|
||||
record CreateTable(TableRef ref, boolean ifNotExists, Table table) implements Statement {
|
||||
}
|
||||
|
||||
record DropTable(TableRef ref, boolean ifExists) implements Statement {
|
||||
}
|
||||
|
||||
/** One partition: its key values in the order written, and its location when one is given. */
|
||||
record PartitionSpec(Map<String, String> values, String location) {
|
||||
}
|
||||
|
||||
record AddPartitions(TableRef ref, boolean ifNotExists, List<PartitionSpec> partitions) implements Statement {
|
||||
}
|
||||
|
||||
record DropPartitions(TableRef ref, boolean ifExists, List<PartitionSpec> partitions) implements Statement {
|
||||
}
|
||||
|
||||
record RepairTable(TableRef ref) implements Statement {
|
||||
}
|
||||
|
||||
record ShowPartitions(TableRef ref) implements Statement {
|
||||
}
|
||||
|
||||
private record Format(String inputFormat, String outputFormat, String serde) {
|
||||
}
|
||||
|
||||
private static final String LAZY_SIMPLE_SERDE = "org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe";
|
||||
private static final Map<String, Format> FORMATS = Map.of(
|
||||
"TEXTFILE", new Format("org.apache.hadoop.mapred.TextInputFormat",
|
||||
"org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat", LAZY_SIMPLE_SERDE),
|
||||
"SEQUENCEFILE", new Format("org.apache.hadoop.mapred.SequenceFileInputFormat",
|
||||
"org.apache.hadoop.hive.ql.io.HiveSequenceFileOutputFormat", LAZY_SIMPLE_SERDE),
|
||||
"RCFILE", new Format("org.apache.hadoop.hive.ql.io.RCFileInputFormat",
|
||||
"org.apache.hadoop.hive.ql.io.RCFileOutputFormat",
|
||||
"org.apache.hadoop.hive.serde2.columnar.LazyBinaryColumnarSerDe"),
|
||||
"ORC", new Format("org.apache.hadoop.hive.ql.io.orc.OrcInputFormat",
|
||||
"org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat", "org.apache.hadoop.hive.ql.io.orc.OrcSerde"),
|
||||
"PARQUET", new Format("org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat",
|
||||
"org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat",
|
||||
"org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe"),
|
||||
"AVRO", new Format("org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat",
|
||||
"org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat",
|
||||
"org.apache.hadoop.hive.serde2.avro.AvroSerDe"),
|
||||
"ION", new Format("com.amazon.ionhiveserde.formats.IonInputFormat",
|
||||
"com.amazon.ionhiveserde.formats.IonOutputFormat", "com.amazon.ionhiveserde.IonHiveSerDe"));
|
||||
|
||||
/** Words that end a column type when they follow it at the top level. */
|
||||
private static final Set<String> TYPE_TERMINATORS = Set.of("COMMENT");
|
||||
|
||||
private final List<Token> tokens;
|
||||
private int position;
|
||||
|
||||
private AthenaHiveDdl(List<Token> tokens) {
|
||||
this.tokens = tokens;
|
||||
}
|
||||
|
||||
/** The statement {@code sql} holds, or null when it is not one of the statements this class runs. */
|
||||
static Statement parse(String sql) {
|
||||
List<Token> tokens = tokenize(sql);
|
||||
if (tokens.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return new AthenaHiveDdl(tokens).statement();
|
||||
}
|
||||
|
||||
private Statement statement() {
|
||||
if (acceptWords("CREATE", "EXTERNAL", "TABLE")) {
|
||||
return finish(createTable());
|
||||
}
|
||||
if (peekWords("CREATE", "TABLE")) {
|
||||
if (isIcebergOrCtas()) {
|
||||
return null;
|
||||
}
|
||||
throw invalid("Athena creates a table without EXTERNAL only as an Iceberg table "
|
||||
+ "(TBLPROPERTIES ('table_type'='ICEBERG')); use CREATE EXTERNAL TABLE for a Hive table");
|
||||
}
|
||||
if (acceptWords("DROP", "TABLE")) {
|
||||
boolean ifExists = acceptWords("IF", "EXISTS");
|
||||
return finish(new DropTable(tableRef(), ifExists));
|
||||
}
|
||||
if (acceptWords("MSCK", "REPAIR", "TABLE")) {
|
||||
return finish(new RepairTable(tableRef()));
|
||||
}
|
||||
if (acceptWords("SHOW", "PARTITIONS")) {
|
||||
return finish(new ShowPartitions(tableRef()));
|
||||
}
|
||||
if (acceptWords("ALTER", "TABLE")) {
|
||||
TableRef ref = tableRef();
|
||||
if (acceptWords("ADD")) {
|
||||
boolean ifNotExists = acceptWords("IF", "NOT", "EXISTS");
|
||||
if (peekWords("PARTITION")) {
|
||||
return finish(new AddPartitions(ref, ifNotExists, partitionSpecs(true)));
|
||||
}
|
||||
} else if (acceptWords("DROP")) {
|
||||
boolean ifExists = acceptWords("IF", "EXISTS");
|
||||
if (peekWords("PARTITION")) {
|
||||
return finish(new DropPartitions(ref, ifExists, partitionSpecs(false)));
|
||||
}
|
||||
}
|
||||
throw invalid("Floci runs ALTER TABLE ADD PARTITION and ALTER TABLE DROP PARTITION; "
|
||||
+ "other ALTER TABLE statements are not supported");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Statement finish(Statement statement) {
|
||||
accept(";");
|
||||
if (position < tokens.size()) {
|
||||
throw invalid("Unexpected '" + tokens.get(position).text() + "' in the statement");
|
||||
}
|
||||
return statement;
|
||||
}
|
||||
|
||||
private boolean isIcebergOrCtas() {
|
||||
for (int i = position; i < tokens.size(); i++) {
|
||||
Token token = tokens.get(i);
|
||||
Token following = i + 1 < tokens.size() ? tokens.get(i + 1) : null;
|
||||
boolean query = following != null && (following.isWord("SELECT") || following.isWord("WITH")
|
||||
|| following.isWord("VALUES") || following.is("("));
|
||||
if (token.isWord("AS") && query || token.isWord("WITH") && following != null && following.is("(")) {
|
||||
return true;
|
||||
}
|
||||
if (token.kind() == Kind.STRING && "table_type".equalsIgnoreCase(token.text())
|
||||
&& i + 2 < tokens.size() && tokens.get(i + 1).is("=")
|
||||
&& "ICEBERG".equalsIgnoreCase(tokens.get(i + 2).text())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private CreateTable createTable() {
|
||||
boolean ifNotExists = acceptWords("IF", "NOT", "EXISTS");
|
||||
TableRef ref = tableRef();
|
||||
Table table = new Table();
|
||||
table.setName(ref.table());
|
||||
table.setTableType("EXTERNAL_TABLE");
|
||||
StorageDescriptor descriptor = new StorageDescriptor();
|
||||
descriptor.setColumns(accept("(") ? columns() : new ArrayList<>());
|
||||
descriptor.setCompressed(false);
|
||||
descriptor.setNumberOfBuckets(-1);
|
||||
descriptor.setStoredAsSubDirectories(false);
|
||||
StorageDescriptor.SerDeInfo serde = new StorageDescriptor.SerDeInfo();
|
||||
Map<String, String> serdeParameters = new LinkedHashMap<>();
|
||||
Map<String, String> tableParameters = new LinkedHashMap<>();
|
||||
List<Column> partitionKeys = new ArrayList<>();
|
||||
String format = null;
|
||||
boolean delimited = false;
|
||||
while (position < tokens.size() && !tokens.get(position).is(";")) {
|
||||
if (acceptWords("COMMENT")) {
|
||||
table.setDescription(string());
|
||||
} else if (acceptWords("PARTITIONED", "BY")) {
|
||||
expect("(");
|
||||
partitionKeys.addAll(columns());
|
||||
} else if (acceptWords("CLUSTERED", "BY")) {
|
||||
descriptor.setBucketColumns(identifierList());
|
||||
if (acceptWords("SORTED", "BY")) {
|
||||
descriptor.setSortColumns(sortColumns());
|
||||
}
|
||||
expectWords("INTO");
|
||||
descriptor.setNumberOfBuckets(Integer.parseInt(next().text()));
|
||||
expectWords("BUCKETS");
|
||||
} else if (acceptWords("ROW", "FORMAT", "DELIMITED")) {
|
||||
delimited = true;
|
||||
delimiters(serdeParameters);
|
||||
} else if (acceptWords("ROW", "FORMAT", "SERDE")) {
|
||||
serde.setSerializationLibrary(string());
|
||||
if (acceptWords("WITH", "SERDEPROPERTIES")) {
|
||||
serdeParameters.putAll(properties());
|
||||
}
|
||||
} else if (acceptWords("STORED", "AS", "INPUTFORMAT")) {
|
||||
descriptor.setInputFormat(string());
|
||||
expectWords("OUTPUTFORMAT");
|
||||
descriptor.setOutputFormat(string());
|
||||
} else if (acceptWords("STORED", "AS")) {
|
||||
format = next().text().toUpperCase(Locale.ROOT);
|
||||
if (!FORMATS.containsKey(format)) {
|
||||
throw invalid("Unsupported STORED AS format: " + format);
|
||||
}
|
||||
} else if (acceptWords("WITH", "SERDEPROPERTIES")) {
|
||||
serdeParameters.putAll(properties());
|
||||
} else if (acceptWords("LOCATION")) {
|
||||
descriptor.setLocation(string());
|
||||
} else if (acceptWords("TBLPROPERTIES")) {
|
||||
tableParameters.putAll(properties());
|
||||
} else {
|
||||
throw invalid("Unexpected '" + tokens.get(position).text() + "' in CREATE EXTERNAL TABLE");
|
||||
}
|
||||
}
|
||||
Format storage = FORMATS.get(format == null ? "TEXTFILE" : format);
|
||||
if (descriptor.getInputFormat() == null) {
|
||||
descriptor.setInputFormat(storage.inputFormat());
|
||||
descriptor.setOutputFormat(storage.outputFormat());
|
||||
}
|
||||
if (serde.getSerializationLibrary() == null) {
|
||||
serde.setSerializationLibrary(delimited ? LAZY_SIMPLE_SERDE : storage.serde());
|
||||
}
|
||||
if (LAZY_SIMPLE_SERDE.equals(serde.getSerializationLibrary())) {
|
||||
serdeParameters.putIfAbsent("serialization.format", "1");
|
||||
}
|
||||
serde.setParameters(serdeParameters);
|
||||
descriptor.setSerdeInfo(serde);
|
||||
table.setStorageDescriptor(descriptor);
|
||||
table.setPartitionKeys(partitionKeys);
|
||||
tableParameters.put("EXTERNAL", "TRUE");
|
||||
table.setParameters(tableParameters);
|
||||
return new CreateTable(ref, ifNotExists, table);
|
||||
}
|
||||
|
||||
/** The {@code ROW FORMAT DELIMITED} clauses, as the SerDe parameters Hive stores for them. */
|
||||
private void delimiters(Map<String, String> parameters) {
|
||||
while (true) {
|
||||
if (acceptWords("FIELDS", "TERMINATED", "BY")) {
|
||||
String delimiter = string();
|
||||
parameters.put("field.delim", delimiter);
|
||||
parameters.put("serialization.format", delimiter);
|
||||
if (acceptWords("ESCAPED", "BY")) {
|
||||
parameters.put("escape.delim", string());
|
||||
}
|
||||
} else if (acceptWords("COLLECTION", "ITEMS", "TERMINATED", "BY")) {
|
||||
// Hive's own spelling of the key.
|
||||
parameters.put("colelction.delim", string());
|
||||
} else if (acceptWords("MAP", "KEYS", "TERMINATED", "BY")) {
|
||||
parameters.put("mapkey.delim", string());
|
||||
} else if (acceptWords("LINES", "TERMINATED", "BY")) {
|
||||
parameters.put("line.delim", string());
|
||||
} else if (acceptWords("NULL", "DEFINED", "AS")) {
|
||||
parameters.put("serialization.null.format", string());
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Column definitions up to and including the closing parenthesis. */
|
||||
private List<Column> columns() {
|
||||
List<Column> columns = new ArrayList<>();
|
||||
do {
|
||||
Column column = new Column();
|
||||
column.setName(identifier());
|
||||
column.setType(type());
|
||||
if (acceptWords("COMMENT")) {
|
||||
column.setComment(string());
|
||||
}
|
||||
columns.add(column);
|
||||
} while (accept(","));
|
||||
expect(")");
|
||||
return columns;
|
||||
}
|
||||
|
||||
/** A column type, written back lower-cased without spaces, as Glue stores it. */
|
||||
private String type() {
|
||||
StringBuilder type = new StringBuilder();
|
||||
int depth = 0;
|
||||
while (position < tokens.size()) {
|
||||
Token token = tokens.get(position);
|
||||
if (depth == 0 && (token.is(",") || token.is(")") || TYPE_TERMINATORS.contains(token.upper()))) {
|
||||
break;
|
||||
}
|
||||
if (token.is("<") || token.is("(")) {
|
||||
depth++;
|
||||
} else if (token.is(">") || token.is(")")) {
|
||||
depth--;
|
||||
}
|
||||
if (!type.isEmpty() && token.kind() == Kind.WORD && Character.isLetterOrDigit(type.charAt(type.length() - 1))) {
|
||||
type.append(' ');
|
||||
}
|
||||
type.append(token.kind() == Kind.WORD ? token.text().toLowerCase(Locale.ROOT) : token.text());
|
||||
position++;
|
||||
}
|
||||
if (type.isEmpty()) {
|
||||
throw invalid("A column is missing its type");
|
||||
}
|
||||
return type.toString();
|
||||
}
|
||||
|
||||
private List<PartitionSpec> partitionSpecs(boolean withLocation) {
|
||||
List<PartitionSpec> specs = new ArrayList<>();
|
||||
do {
|
||||
expectWords("PARTITION");
|
||||
expect("(");
|
||||
Map<String, String> values = new LinkedHashMap<>();
|
||||
do {
|
||||
String key = identifier();
|
||||
expect("=");
|
||||
Token value = next();
|
||||
if (value.kind() != Kind.STRING && value.kind() != Kind.NUMBER) {
|
||||
throw invalid("A partition value must be a literal, not '" + value.text() + "'");
|
||||
}
|
||||
values.put(key, value.text());
|
||||
} while (accept(","));
|
||||
expect(")");
|
||||
String location = withLocation && acceptWords("LOCATION") ? string() : null;
|
||||
specs.add(new PartitionSpec(values, location));
|
||||
} while (accept(",") || peekWords("PARTITION"));
|
||||
return specs;
|
||||
}
|
||||
|
||||
private Map<String, String> properties() {
|
||||
expect("(");
|
||||
Map<String, String> properties = new LinkedHashMap<>();
|
||||
do {
|
||||
String key = string();
|
||||
expect("=");
|
||||
properties.put(key, string());
|
||||
} while (accept(","));
|
||||
expect(")");
|
||||
return properties;
|
||||
}
|
||||
|
||||
private List<String> identifierList() {
|
||||
expect("(");
|
||||
List<String> names = new ArrayList<>();
|
||||
do {
|
||||
names.add(identifier());
|
||||
} while (accept(","));
|
||||
expect(")");
|
||||
return names;
|
||||
}
|
||||
|
||||
/** {@code SORTED BY} columns as Glue stores them: 1 for ascending, the default, 0 for descending. */
|
||||
private List<StorageDescriptor.Order> sortColumns() {
|
||||
expect("(");
|
||||
List<StorageDescriptor.Order> orders = new ArrayList<>();
|
||||
do {
|
||||
StorageDescriptor.Order order = new StorageDescriptor.Order();
|
||||
order.setColumn(identifier());
|
||||
order.setSortOrder(acceptWords("DESC") ? 0 : 1);
|
||||
acceptWords("ASC");
|
||||
orders.add(order);
|
||||
} while (accept(","));
|
||||
expect(")");
|
||||
return orders;
|
||||
}
|
||||
|
||||
private TableRef tableRef() {
|
||||
String first = identifier();
|
||||
if (accept(".")) {
|
||||
return new TableRef(first, identifier());
|
||||
}
|
||||
return new TableRef(null, first);
|
||||
}
|
||||
|
||||
private String identifier() {
|
||||
Token token = next();
|
||||
if (token.kind() != Kind.WORD && token.kind() != Kind.QUOTED) {
|
||||
throw invalid("Expected a name but found '" + token.text() + "'");
|
||||
}
|
||||
return token.text().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
private String string() {
|
||||
Token token = next();
|
||||
if (token.kind() != Kind.STRING) {
|
||||
throw invalid("Expected a string literal but found '" + token.text() + "'");
|
||||
}
|
||||
return token.text();
|
||||
}
|
||||
|
||||
private Token next() {
|
||||
if (position >= tokens.size()) {
|
||||
throw invalid("The statement ends early");
|
||||
}
|
||||
return tokens.get(position++);
|
||||
}
|
||||
|
||||
private boolean accept(String symbol) {
|
||||
if (position < tokens.size() && tokens.get(position).is(symbol)) {
|
||||
position++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void expect(String symbol) {
|
||||
if (!accept(symbol)) {
|
||||
throw invalid("Expected '" + symbol + "'"
|
||||
+ (position < tokens.size() ? " but found '" + tokens.get(position).text() + "'" : " at the end"));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean peekWords(String... words) {
|
||||
if (position + words.length > tokens.size()) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < words.length; i++) {
|
||||
if (!tokens.get(position + i).isWord(words[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean acceptWords(String... words) {
|
||||
if (!peekWords(words)) {
|
||||
return false;
|
||||
}
|
||||
position += words.length;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void expectWords(String... words) {
|
||||
if (!acceptWords(words)) {
|
||||
throw invalid("Expected " + String.join(" ", words)
|
||||
+ (position < tokens.size() ? " but found '" + tokens.get(position).text() + "'" : " at the end"));
|
||||
}
|
||||
}
|
||||
|
||||
private static AwsException invalid(String message) {
|
||||
return new AwsException("InvalidRequestException", message, 400);
|
||||
}
|
||||
|
||||
// ---- tokenizer ----
|
||||
|
||||
private enum Kind { WORD, QUOTED, STRING, NUMBER, SYMBOL }
|
||||
|
||||
private record Token(Kind kind, String text) {
|
||||
boolean is(String symbol) {
|
||||
return kind == Kind.SYMBOL && text.equals(symbol);
|
||||
}
|
||||
|
||||
boolean isWord(String word) {
|
||||
return kind == Kind.WORD && text.equalsIgnoreCase(word);
|
||||
}
|
||||
|
||||
String upper() {
|
||||
return kind == Kind.WORD ? text.toUpperCase(Locale.ROOT) : "";
|
||||
}
|
||||
}
|
||||
|
||||
private static List<Token> tokenize(String sql) {
|
||||
List<Token> tokens = new ArrayList<>();
|
||||
int i = 0;
|
||||
int length = sql == null ? 0 : sql.length();
|
||||
while (i < length) {
|
||||
char c = sql.charAt(i);
|
||||
if (Character.isWhitespace(c)) {
|
||||
i++;
|
||||
} else if (sql.startsWith("--", i)) {
|
||||
int end = sql.indexOf('\n', i);
|
||||
i = end < 0 ? length : end + 1;
|
||||
} else if (sql.startsWith("/*", i)) {
|
||||
int end = sql.indexOf("*/", i + 2);
|
||||
i = end < 0 ? length : end + 2;
|
||||
} else if (Character.isLetter(c) || c == '_') {
|
||||
int start = i;
|
||||
while (i < length && (Character.isLetterOrDigit(sql.charAt(i)) || sql.charAt(i) == '_'
|
||||
|| sql.charAt(i) == '$')) {
|
||||
i++;
|
||||
}
|
||||
tokens.add(new Token(Kind.WORD, sql.substring(start, i)));
|
||||
} else if (Character.isDigit(c)) {
|
||||
int start = i;
|
||||
while (i < length && (Character.isDigit(sql.charAt(i)) || sql.charAt(i) == '.')) {
|
||||
i++;
|
||||
}
|
||||
tokens.add(new Token(Kind.NUMBER, sql.substring(start, i)));
|
||||
} else if (c == '`') {
|
||||
StringBuilder name = new StringBuilder();
|
||||
i++;
|
||||
while (i < length) {
|
||||
if (sql.charAt(i) == '`') {
|
||||
if (i + 1 < length && sql.charAt(i + 1) == '`') {
|
||||
name.append('`');
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
name.append(sql.charAt(i++));
|
||||
}
|
||||
i = Math.min(i + 1, length);
|
||||
tokens.add(new Token(Kind.QUOTED, name.toString()));
|
||||
} else if (c == '\'' || c == '"') {
|
||||
StringBuilder value = new StringBuilder();
|
||||
i = readString(sql, i, value);
|
||||
tokens.add(new Token(Kind.STRING, value.toString()));
|
||||
} else {
|
||||
// Any other character is a symbol of its own: tokenizing never fails, so a statement this
|
||||
// class does not run reaches the query engine with the engine's own error, not this one's.
|
||||
tokens.add(new Token(Kind.SYMBOL, String.valueOf(c)));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return tokens;
|
||||
}
|
||||
|
||||
/** Reads the Hive string literal at {@code start} into {@code value}, returning the index after it. */
|
||||
private static int readString(String sql, int start, StringBuilder value) {
|
||||
char quote = sql.charAt(start);
|
||||
int i = start + 1;
|
||||
while (i < sql.length()) {
|
||||
char c = sql.charAt(i);
|
||||
if (c == quote) {
|
||||
if (i + 1 < sql.length() && sql.charAt(i + 1) == quote) {
|
||||
value.append(quote);
|
||||
i += 2;
|
||||
continue;
|
||||
}
|
||||
return i + 1;
|
||||
}
|
||||
if (c == '\\' && i + 1 < sql.length()) {
|
||||
i = readEscape(sql, i + 1, value);
|
||||
continue;
|
||||
}
|
||||
value.append(c);
|
||||
i++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
private static int readEscape(String sql, int i, StringBuilder value) {
|
||||
char c = sql.charAt(i);
|
||||
switch (c) {
|
||||
case 't' -> value.append('\t');
|
||||
case 'n' -> value.append('\n');
|
||||
case 'r' -> value.append('\r');
|
||||
case 'b' -> value.append('\b');
|
||||
case 'f' -> value.append('\f');
|
||||
case 'u' -> {
|
||||
if (i + 4 < sql.length()) {
|
||||
value.append((char) Integer.parseInt(sql.substring(i + 1, i + 5), 16));
|
||||
return i + 5;
|
||||
}
|
||||
value.append(c);
|
||||
}
|
||||
default -> {
|
||||
if (c >= '0' && c <= '7') {
|
||||
int end = i;
|
||||
while (end < sql.length() && end < i + 3 && sql.charAt(end) >= '0' && sql.charAt(end) <= '7') {
|
||||
end++;
|
||||
}
|
||||
value.append((char) Integer.parseInt(sql.substring(i, end), 8));
|
||||
return end;
|
||||
}
|
||||
value.append(c);
|
||||
}
|
||||
}
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,345 @@
|
||||
package io.floci.aws.services.athena;
|
||||
|
||||
import io.floci.aws.core.common.AwsException;
|
||||
import io.floci.aws.services.glue.GlueService;
|
||||
import io.floci.aws.services.glue.GlueTableResolver;
|
||||
import io.floci.aws.services.glue.model.Column;
|
||||
import io.floci.aws.services.glue.model.Partition;
|
||||
import io.floci.aws.services.glue.model.StorageDescriptor;
|
||||
import io.floci.aws.services.glue.model.Table;
|
||||
import io.floci.aws.services.s3.S3Service;
|
||||
import io.floci.aws.services.s3.model.S3Object;
|
||||
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Runs an {@link AthenaHiveDdl} statement against the Glue Data Catalog, the way Athena runs it:
|
||||
* {@code DROP TABLE} removes only a Hive table's metadata, and an Iceberg table's data with it, as
|
||||
* Athena treats Iceberg tables as managed; {@code MSCK REPAIR TABLE}
|
||||
* adds the Hive-style {@code key=value} partitions it finds under the table's location and never
|
||||
* removes any; {@code IF [NOT] EXISTS} turns a duplicate or missing table or partition from an
|
||||
* error into a no-op.
|
||||
*/
|
||||
final class AthenaHiveDdlExecutor {
|
||||
|
||||
private static final int LIST_PAGE_SIZE = 1000;
|
||||
private static final String HIVE_ESCAPED_CHARACTERS = "\"#%'*/:=?\\{[]^";
|
||||
|
||||
private final GlueService glueService;
|
||||
private final S3Service s3Service;
|
||||
|
||||
AthenaHiveDdlExecutor(GlueService glueService, S3Service s3Service) {
|
||||
this.glueService = glueService;
|
||||
this.s3Service = s3Service;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs {@code statement}, a table it names without a database being in {@code contextDatabase}.
|
||||
* Returns the result rows of {@code SHOW PARTITIONS}, one {@code key=value[/key=value...]} string
|
||||
* each, and no rows for every other statement.
|
||||
*/
|
||||
List<String> execute(AthenaHiveDdl.Statement statement, String contextDatabase) {
|
||||
String database = statement.ref().database() != null ? statement.ref().database() : contextDatabase;
|
||||
String table = statement.ref().table();
|
||||
return switch (statement) {
|
||||
case AthenaHiveDdl.CreateTable create -> {
|
||||
createTable(database, create);
|
||||
yield List.of();
|
||||
}
|
||||
case AthenaHiveDdl.DropTable drop -> {
|
||||
dropTable(database, table, drop.ifExists());
|
||||
yield List.of();
|
||||
}
|
||||
case AthenaHiveDdl.AddPartitions add -> {
|
||||
addPartitions(database, existingTable(database, table), add);
|
||||
yield List.of();
|
||||
}
|
||||
case AthenaHiveDdl.DropPartitions drop -> {
|
||||
dropPartitions(database, existingTable(database, table), drop);
|
||||
yield List.of();
|
||||
}
|
||||
case AthenaHiveDdl.RepairTable repair -> {
|
||||
repair(database, existingTable(database, table));
|
||||
yield List.of();
|
||||
}
|
||||
case AthenaHiveDdl.ShowPartitions show -> partitionNames(database, existingTable(database, table));
|
||||
};
|
||||
}
|
||||
|
||||
private void createTable(String database, AthenaHiveDdl.CreateTable create) {
|
||||
create.table().setDatabaseName(database);
|
||||
try {
|
||||
glueService.createTable(database, create.table());
|
||||
} catch (AwsException e) {
|
||||
if (!create.ifNotExists() || !"AlreadyExistsException".equals(e.getErrorCode())) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dropTable(String database, String table, boolean ifExists) {
|
||||
Table found = findTable(database, table);
|
||||
if (found == null) {
|
||||
if (ifExists) {
|
||||
return;
|
||||
}
|
||||
throw tableNotFound(database, table);
|
||||
}
|
||||
try {
|
||||
glueService.deleteTable(database, table);
|
||||
} catch (AwsException e) {
|
||||
// Another drop can remove the table between the lookup and the delete.
|
||||
if (!ifExists || !"EntityNotFoundException".equals(e.getErrorCode())) {
|
||||
throw e;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (GlueTableResolver.isIcebergTable(found)) {
|
||||
// Athena treats an Iceberg table as managed: dropping it removes its data too.
|
||||
deleteObjectsUnder(found.getStorageDescriptor() != null ? found.getStorageDescriptor().getLocation() : null);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteObjectsUnder(String location) {
|
||||
S3Prefix prefix = S3Prefix.of(location);
|
||||
if (prefix == null) {
|
||||
return;
|
||||
}
|
||||
String continuation = null;
|
||||
do {
|
||||
S3Service.ListObjectsResult page = s3Service.listObjectsWithPrefixes(prefix.bucket(), prefix.prefix(), null,
|
||||
LIST_PAGE_SIZE, continuation, null);
|
||||
for (S3Object object : page.objects()) {
|
||||
s3Service.deleteObject(prefix.bucket(), object.getKey());
|
||||
}
|
||||
continuation = page.isTruncated() ? page.nextContinuationToken() : null;
|
||||
} while (continuation != null);
|
||||
}
|
||||
|
||||
/** An {@code s3://bucket/prefix/} location split into its bucket and its key prefix, ending in a slash. */
|
||||
private record S3Prefix(String bucket, String prefix) {
|
||||
static S3Prefix of(String location) {
|
||||
if (location == null || !location.startsWith("s3://")) {
|
||||
return null;
|
||||
}
|
||||
String withoutScheme = location.substring("s3://".length());
|
||||
int slash = withoutScheme.indexOf('/');
|
||||
String bucket = slash < 0 ? withoutScheme : withoutScheme.substring(0, slash);
|
||||
String prefix = slash < 0 ? "" : withoutScheme.substring(slash + 1);
|
||||
return new S3Prefix(bucket, prefix.isEmpty() || prefix.endsWith("/") ? prefix : prefix + "/");
|
||||
}
|
||||
}
|
||||
|
||||
private void addPartitions(String database, Table table, AthenaHiveDdl.AddPartitions add) {
|
||||
for (AthenaHiveDdl.PartitionSpec spec : add.partitions()) {
|
||||
List<String> values = orderedValues(table, spec);
|
||||
createPartition(database, table, values,
|
||||
spec.location() != null ? spec.location() : defaultLocation(table, values), add.ifNotExists());
|
||||
}
|
||||
}
|
||||
|
||||
private void dropPartitions(String database, Table table, AthenaHiveDdl.DropPartitions drop) {
|
||||
for (AthenaHiveDdl.PartitionSpec spec : drop.partitions()) {
|
||||
List<String> values = orderedValues(table, spec);
|
||||
try {
|
||||
glueService.deletePartition(database, table.getName(), values);
|
||||
} catch (AwsException e) {
|
||||
if (!drop.ifExists() || !"EntityNotFoundException".equals(e.getErrorCode())) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Adds every complete {@code key=value/...} folder path under the table's location that has no partition yet. */
|
||||
private void repair(String database, Table table) {
|
||||
List<Column> keys = partitionKeys(table);
|
||||
S3Prefix root = S3Prefix.of(table.getStorageDescriptor() != null ? table.getStorageDescriptor().getLocation() : null);
|
||||
if (keys.isEmpty() || root == null) {
|
||||
return;
|
||||
}
|
||||
Set<List<String>> existing = glueService.getPartitions(database, table.getName()).stream()
|
||||
.map(Partition::getValues)
|
||||
.collect(Collectors.toCollection(HashSet::new));
|
||||
// Each new partition's values and the folder they were found in, kept as spelled in S3.
|
||||
Map<List<String>, String> found = new LinkedHashMap<>();
|
||||
String continuation = null;
|
||||
do {
|
||||
S3Service.ListObjectsResult page = s3Service.listObjectsWithPrefixes(root.bucket(), root.prefix(), null,
|
||||
LIST_PAGE_SIZE, continuation, null);
|
||||
for (S3Object object : page.objects()) {
|
||||
String relative = object.getKey().substring(root.prefix().length());
|
||||
List<String> values = hivePartitionValues(relative, keys);
|
||||
if (values != null && !existing.contains(values)) {
|
||||
found.putIfAbsent(values, "s3://" + root.bucket() + "/" + root.prefix()
|
||||
+ String.join("/", Arrays.asList(relative.split("/", -1)).subList(0, keys.size())) + "/");
|
||||
}
|
||||
}
|
||||
continuation = page.isTruncated() ? page.nextContinuationToken() : null;
|
||||
} while (continuation != null);
|
||||
found.forEach((values, location) -> createPartition(database, table, values, location, true));
|
||||
}
|
||||
|
||||
private void createPartition(String database, Table table, List<String> values, String location,
|
||||
boolean tolerateExisting) {
|
||||
Partition partition = new Partition();
|
||||
partition.setValues(values);
|
||||
partition.setStorageDescriptor(partitionDescriptor(table, location));
|
||||
try {
|
||||
glueService.createPartition(database, table.getName(), partition);
|
||||
} catch (AwsException e) {
|
||||
if (!tolerateExisting || !"AlreadyExistsException".equals(e.getErrorCode())) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The partition values the leading folders of {@code relativeKey} name, one {@code key=value}
|
||||
* folder per partition key in order, or null when they do not. A key is matched without regard to
|
||||
* case and a value is unescaped as Hive escapes folder names ({@code %2F} for {@code /}).
|
||||
*/
|
||||
static List<String> hivePartitionValues(String relativeKey, List<Column> keys) {
|
||||
String[] segments = relativeKey.split("/", -1);
|
||||
if (segments.length <= keys.size()) {
|
||||
return null;
|
||||
}
|
||||
List<String> values = new ArrayList<>();
|
||||
for (int i = 0; i < keys.size(); i++) {
|
||||
String segment = segments[i];
|
||||
int equals = segment.indexOf('=');
|
||||
if (equals <= 0 || !segment.substring(0, equals).equalsIgnoreCase(keys.get(i).getName())) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
values.add(URLDecoder.decode(segment.substring(equals + 1).replace("+", "%2B"), StandardCharsets.UTF_8));
|
||||
} catch (IllegalArgumentException malformedEscape) {
|
||||
// A folder name Hive could not have written is not a partition folder.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
private List<String> partitionNames(String database, Table table) {
|
||||
List<Column> keys = partitionKeys(table);
|
||||
List<String> names = new ArrayList<>();
|
||||
for (Partition partition : glueService.getPartitions(database, table.getName())) {
|
||||
List<String> parts = new ArrayList<>();
|
||||
for (int i = 0; i < keys.size() && i < partition.getValues().size(); i++) {
|
||||
parts.add(keys.get(i).getName() + "=" + escapePathName(partition.getValues().get(i)));
|
||||
}
|
||||
names.add(String.join("/", parts));
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
/** The spec's values in the table's partition-key order; the spec has to name every key once. */
|
||||
private static List<String> orderedValues(Table table, AthenaHiveDdl.PartitionSpec spec) {
|
||||
List<Column> keys = partitionKeys(table);
|
||||
Map<String, String> values = spec.values();
|
||||
Set<String> named = values.keySet().stream().map(k -> k.toLowerCase(Locale.ROOT)).collect(Collectors.toSet());
|
||||
Set<String> declared = keys.stream().map(k -> k.getName().toLowerCase(Locale.ROOT)).collect(Collectors.toSet());
|
||||
if (keys.isEmpty() || !named.equals(declared) || named.size() != values.size()) {
|
||||
throw new AwsException("InvalidRequestException", "The partition specification " + values.keySet()
|
||||
+ " does not match the partition keys of table " + table.getName() + ": " + declared, 400);
|
||||
}
|
||||
List<String> ordered = new ArrayList<>();
|
||||
for (Column key : keys) {
|
||||
values.forEach((name, value) -> {
|
||||
if (name.equalsIgnoreCase(key.getName())) {
|
||||
ordered.add(value);
|
||||
}
|
||||
});
|
||||
}
|
||||
return ordered;
|
||||
}
|
||||
|
||||
/** Athena's location for a partition added without one: {@code <table location>/key=value/...}. */
|
||||
private static String defaultLocation(Table table, List<String> values) {
|
||||
String location = table.getStorageDescriptor() != null && table.getStorageDescriptor().getLocation() != null
|
||||
? table.getStorageDescriptor().getLocation() : "";
|
||||
StringBuilder path = new StringBuilder(location.endsWith("/") ? location : location + "/");
|
||||
List<Column> keys = partitionKeys(table);
|
||||
for (int i = 0; i < keys.size(); i++) {
|
||||
path.append(keys.get(i).getName()).append('=').append(escapePathName(values.get(i))).append('/');
|
||||
}
|
||||
return path.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code value} as Hive writes it in a partition folder name and in {@code SHOW PARTITIONS}: the
|
||||
* characters Hive's {@code FileUtils.escapePathName} escapes become {@code %XX}.
|
||||
*/
|
||||
static String escapePathName(String value) {
|
||||
StringBuilder escaped = new StringBuilder(value.length());
|
||||
for (char c : value.toCharArray()) {
|
||||
if (c < 0x20 || c == 0x7F || HIVE_ESCAPED_CHARACTERS.indexOf(c) >= 0) {
|
||||
escaped.append('%').append(String.format(Locale.ROOT, "%02X", (int) c));
|
||||
} else {
|
||||
escaped.append(c);
|
||||
}
|
||||
}
|
||||
return escaped.toString();
|
||||
}
|
||||
|
||||
/** The table's storage descriptor with the partition's own location. */
|
||||
private static StorageDescriptor partitionDescriptor(Table table, String location) {
|
||||
StorageDescriptor source = table.getStorageDescriptor();
|
||||
StorageDescriptor descriptor = new StorageDescriptor();
|
||||
if (source != null) {
|
||||
descriptor.setColumns(source.getColumns());
|
||||
descriptor.setInputFormat(source.getInputFormat());
|
||||
descriptor.setOutputFormat(source.getOutputFormat());
|
||||
descriptor.setCompressed(source.getCompressed());
|
||||
descriptor.setNumberOfBuckets(source.getNumberOfBuckets());
|
||||
descriptor.setSerdeInfo(source.getSerdeInfo());
|
||||
descriptor.setBucketColumns(source.getBucketColumns());
|
||||
descriptor.setSortColumns(source.getSortColumns());
|
||||
descriptor.setParameters(source.getParameters());
|
||||
descriptor.setSkewedInfo(source.getSkewedInfo());
|
||||
descriptor.setStoredAsSubDirectories(source.getStoredAsSubDirectories());
|
||||
descriptor.setSchemaReference(source.getSchemaReference());
|
||||
descriptor.setAdditionalLocations(source.getAdditionalLocations());
|
||||
}
|
||||
descriptor.setLocation(location);
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
private static List<Column> partitionKeys(Table table) {
|
||||
return table.getPartitionKeys() == null ? List.of() : table.getPartitionKeys();
|
||||
}
|
||||
|
||||
private Table existingTable(String database, String table) {
|
||||
Table found = findTable(database, table);
|
||||
if (found == null) {
|
||||
throw tableNotFound(database, table);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
private Table findTable(String database, String table) {
|
||||
try {
|
||||
return glueService.getTable(database, table);
|
||||
} catch (AwsException e) {
|
||||
if ("EntityNotFoundException".equals(e.getErrorCode())) {
|
||||
return null;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private static AwsException tableNotFound(String database, String table) {
|
||||
return new AwsException("InvalidRequestException", "Table not found: " + database + "." + table, 400);
|
||||
}
|
||||
}
|
||||
@@ -109,6 +109,7 @@ public class AthenaService {
|
||||
private final Vertx vertx;
|
||||
private final GlueViewDdlBuilder ddlBuilder;
|
||||
private final RegionResolver regionResolver;
|
||||
private final AthenaHiveDdlExecutor hiveDdlExecutor;
|
||||
|
||||
@Inject
|
||||
public AthenaService(StorageFactory storageFactory,
|
||||
@@ -134,6 +135,7 @@ public class AthenaService {
|
||||
this.vertx = vertx;
|
||||
this.ddlBuilder = ddlBuilder;
|
||||
this.regionResolver = regionResolver;
|
||||
this.hiveDdlExecutor = new AthenaHiveDdlExecutor(glueService, s3Service);
|
||||
}
|
||||
|
||||
public String startQueryExecution(String query,
|
||||
@@ -149,6 +151,16 @@ public class AthenaService {
|
||||
}
|
||||
|
||||
boolean createDatabaseStatement = CREATE_DATABASE_PREFIX_PATTERN.matcher(statementText(query)).find();
|
||||
// Hive DDL runs against the Glue catalog, not the query engine. A statement that starts like one but
|
||||
// does not parse fails the query with the parser's reason rather than reaching DuckDB.
|
||||
AthenaHiveDdl.Statement hiveDdl = null;
|
||||
AwsException invalidHiveDdl = null;
|
||||
try {
|
||||
hiveDdl = AthenaHiveDdl.parse(query);
|
||||
} catch (AwsException e) {
|
||||
invalidHiveDdl = e;
|
||||
}
|
||||
boolean hiveDdlStatement = hiveDdl != null || invalidHiveDdl != null;
|
||||
// AWS reports the result CSV object itself as the OutputLocation, not a
|
||||
// directory prefix — the same key is written and returned to the client.
|
||||
// Statements that do not return rows must not be wrapped in a result COPY.
|
||||
@@ -160,12 +172,28 @@ public class AthenaService {
|
||||
: null;
|
||||
|
||||
QueryExecution execution = new QueryExecution(id, query, workGroup, resolvedResult, resolvedContext);
|
||||
if (createDatabaseStatement) {
|
||||
if (createDatabaseStatement || hiveDdlStatement) {
|
||||
execution.setStatementType("DDL");
|
||||
}
|
||||
execution.getStatus().setState(QueryExecutionState.RUNNING);
|
||||
queryStore.put(id, execution);
|
||||
|
||||
if (hiveDdlStatement) {
|
||||
try {
|
||||
if (invalidHiveDdl != null) {
|
||||
throw invalidHiveDdl;
|
||||
}
|
||||
List<String> rows = hiveDdlExecutor.execute(hiveDdl, database);
|
||||
if (outputLocation != null) {
|
||||
writeSingleColumnResult(id, outputLocation, "partition", rows);
|
||||
}
|
||||
markSucceeded(id, execution);
|
||||
} catch (Exception e) {
|
||||
markFailed(id, execution, e);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
if (createDatabaseStatement) {
|
||||
try {
|
||||
CreateDatabaseDdl createDatabaseDdl = parseCreateDatabase(query);
|
||||
@@ -556,7 +584,8 @@ public class AthenaService {
|
||||
throw new AwsException("InvalidRequestException", "Query has not succeeded yet", 400);
|
||||
}
|
||||
|
||||
if (config.services().athena().mock()
|
||||
// DDL rows (SHOW PARTITIONS) come from the Glue catalog, not the query engine, so mock mode keeps them.
|
||||
if (config.services().athena().mock() && !"DDL".equals(execution.getStatementType())
|
||||
|| execution.getResultConfiguration() == null
|
||||
|| execution.getResultConfiguration().getOutputLocation() == null) {
|
||||
return new ResultSet(List.of(), new ResultSet.ResultSetMetadata(List.of()));
|
||||
@@ -1120,6 +1149,18 @@ public class AthenaService {
|
||||
}
|
||||
}
|
||||
|
||||
/** Writes {@code rows} as a one-column result CSV, the shape the query engine writes, typed varchar. */
|
||||
private void writeSingleColumnResult(String id, String outputLocation, String column, List<String> rows) {
|
||||
ensureOutputBucket(outputLocation);
|
||||
StringBuilder csv = new StringBuilder(column).append('\n');
|
||||
for (String row : rows) {
|
||||
csv.append('"').append(row.replace("\"", "\"\"")).append("\"\n");
|
||||
}
|
||||
s3Service.putObject(extractBucket(outputLocation), extractKey(outputLocation),
|
||||
csv.toString().getBytes(StandardCharsets.UTF_8), "text/csv", null);
|
||||
resultColumnTypeStore.put(id, List.of("VARCHAR"));
|
||||
}
|
||||
|
||||
private void ensureOutputBucket(String s3Path) {
|
||||
String bucket = extractBucket(s3Path);
|
||||
if (bucket != null) {
|
||||
|
||||
Reference in new issue
Block a user