File tree Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -1386,6 +1386,20 @@ impl ConfigField for TableParquetOptions {
1386
1386
// Determine the key if it's a global or column-specific setting
1387
1387
if key. contains ( "::" ) {
1388
1388
self . column_specific_options . set ( key, value)
1389
+ } else if key. eq ( "metadata" ) {
1390
+ for maybe_pair in value. split ( '_' ) {
1391
+ let ( k, v) = match maybe_pair. split ( ':' ) . collect :: < Vec < _ > > ( ) [ ..] {
1392
+ [ k, v] => ( k. into ( ) , Some ( v. into ( ) ) ) ,
1393
+ [ k] => ( k. into ( ) , None ) ,
1394
+ _ => {
1395
+ return Err ( DataFusionError :: Configuration ( format ! (
1396
+ "Invalid metadata provided \" {maybe_pair}\" "
1397
+ ) ) )
1398
+ }
1399
+ } ;
1400
+ self . key_value_metadata . insert ( k, v) ;
1401
+ }
1402
+ Ok ( ( ) )
1389
1403
} else {
1390
1404
self . global . set ( key, value)
1391
1405
}
Original file line number Diff line number Diff line change @@ -283,11 +283,38 @@ OPTIONS (
283
283
'format.statistics_enabled::col2' none,
284
284
'format.max_statistics_size' 123,
285
285
'format.bloom_filter_fpp' 0.001,
286
- 'format.bloom_filter_ndv' 100
286
+ 'format.bloom_filter_ndv' 100,
287
+ 'format.metadata' 'foo:bar baz'
287
288
)
288
289
----
289
290
2
290
291
292
+ # valid vs invalid metadata
293
+
294
+ statement ok
295
+ COPY source_table
296
+ TO 'test_files/scratch/copy/table_with_metadata/'
297
+ STORED AS PARQUET
298
+ OPTIONS (
299
+ 'format.metadata' ''
300
+ )
301
+
302
+ statement error
303
+ COPY source_table
304
+ TO 'test_files/scratch/copy/table_with_metadata/'
305
+ STORED AS PARQUET
306
+ OPTIONS (
307
+ 'format.metadata' 'foo:bar:extra'
308
+ )
309
+
310
+ statement error
311
+ COPY source_table
312
+ TO 'test_files/scratch/copy/table_with_metadata/'
313
+ STORED AS PARQUET
314
+ OPTIONS (
315
+ 'format.wrong-metadata-key' 'foo:bar baz'
316
+ )
317
+
291
318
# validate multiple parquet file output with all options set
292
319
statement ok
293
320
CREATE EXTERNAL TABLE validate_parquet_with_options STORED AS PARQUET LOCATION 'test_files/scratch/copy/table_with_options/';
You can’t perform that action at this time.
0 commit comments