Skip to content

Commit a74d802

Browse files
sfc-gh-mslotclaude
andcommitted
Add pg_lake_table.enable_partitioned_write_pushdown GUC
Adds a setting to control whether partitioned writes use DuckDB PARTITION_BY pushdown (default: on). When off, partitioned writes fall back to row-by-row processing which supports file_size_bytes splitting. Applies to both INSERT..SELECT and COPY FROM paths. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b49446c commit a74d802

4 files changed

Lines changed: 32 additions & 0 deletions

File tree

pg_lake_copy/src/copy/copy.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,9 @@ IsCopyFromPushdownable(Relation relation, List *columnNameList,
659659
*/
660660
const char *partitionBy = GetIcebergTablePartitionByOption(relationId);
661661

662+
if (partitionBy != NULL && !EnablePartitionedWritePushdown)
663+
return false;
664+
662665
if (partitionBy != NULL &&
663666
GetPartitionByExpressionsForRelation(relationId) == NIL)
664667
return false;

pg_lake_table/include/pg_lake/planner/insert_select.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
/* pg_lake_table.enable_insert_select_pushdown setting */
2424
extern bool EnableInsertSelectPushdown;
2525

26+
/* pg_lake_table.enable_partitioned_write_pushdown setting */
27+
extern PGDLLEXPORT bool EnablePartitionedWritePushdown;
28+
2629
bool IsPushdownableInsertSelectQuery(Query *query);
2730
bool IsInsertSelectQuery(Query *query);
2831
Oid GetInsertRelidFromInsertSelect(Query *query);

pg_lake_table/src/init.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,20 @@ _PG_init(void)
129129
NULL,
130130
NULL);
131131

132+
DefineCustomBoolVariable("pg_lake_table.enable_partitioned_write_pushdown",
133+
"Enables pushdown of partitioned writes to DuckDB "
134+
"using PARTITION_BY. When off, partitioned writes "
135+
"use row-by-row processing which supports "
136+
"file_size_bytes splitting.",
137+
NULL,
138+
&EnablePartitionedWritePushdown,
139+
true,
140+
PGC_USERSET,
141+
GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE,
142+
NULL,
143+
NULL,
144+
NULL);
145+
132146
DefineCustomBoolVariable("pg_lake_table.enable_data_file_pruning",
133147
"Enables data file pruning based on the metadata statistics "
134148
"for iceberg tables.",

pg_lake_table/src/planner/insert_select.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ static bool TypeContainsUnsuitableForPushdown(Oid typeId, int32 typmod, CopyData
4444
/* pg_lake_table.enable_insert_select_pushdown setting */
4545
bool EnableInsertSelectPushdown = true;
4646

47+
/* pg_lake_table.enable_partitioned_write_pushdown setting */
48+
bool EnablePartitionedWritePushdown = true;
49+
4750
/*
4851
* IsPushdownableInsertSelectQuery checks whether the given query is an INSERT..SELECT
4952
* that can be delegated.
@@ -126,6 +129,15 @@ IsPushdownableInsertSelectQuery(Query *query)
126129
*/
127130
const char *partitionBy = GetIcebergTablePartitionByOption(insertIntoRelid);
128131

132+
if (partitionBy != NULL && !EnablePartitionedWritePushdown)
133+
{
134+
ereport(DEBUG4,
135+
(errmsg("INSERT..SELECT into partitioned table is not "
136+
"pushdownable (enable_partitioned_write_pushdown is off)")));
137+
RelationClose(insertRelation);
138+
return false;
139+
}
140+
129141
if (partitionBy != NULL &&
130142
GetPartitionByExpressionsForRelation(insertIntoRelid) == NIL)
131143
{

0 commit comments

Comments
 (0)