File tree Expand file tree Collapse file tree 4 files changed +21
-9
lines changed
wrappers/src/fdw/clickhouse_fdw Expand file tree Collapse file tree 4 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -97,11 +97,14 @@ The following options are available when creating ClickHouse foreign tables:
9797
9898- ` table ` - Source table name in ClickHouse, required
9999
100- This can also be a subquery enclosed in parentheses, for example,
100+ This can also be a subquery enclosed in parentheses, for example,
101101
102- ``` sql
103- table ' (select * from my_table)'
104- ```
102+ ``` sql
103+ table ' (select * from my_table)'
104+ ```
105+
106+ - ` rowid_column` - Primary key column name, optional for data scan, required for data modify
107+ - ` stream_buffer_size` - Size of the internal buffer used for streaming data from ClickHouse, defaults to 1024 rows. Must be between 1 and 100000 .
105108
106109# ## Parametrized views
107110
@@ -123,8 +126,6 @@ table '(select * from my_table)'
123126 select * from test_vw where _param1='aaa' and _param2=32;
124127` ` `
125128
126- - ` rowid_column ` - Primary key column name, optional for data scan, required for data modify
127-
128129# # Entities
129130
130131# ## Tables
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ This is a foreign data wrapper for [ClickHouse](https://clickhouse.com/). It is
1111
1212| Version | Date | Notes |
1313| ------- | ---------- | ---------------------------------------------------- |
14+ | 0.1.9 | 2025-11-08 | Added stream_buffer_size foreign table option |
1415| 0.1.8 | 2025-10-27 | Refactor to read rows with async streaming |
1516| 0.1.7 | 2025-05-22 | Added more data types support |
1617| 0.1.6 | 2025-05-06 | Added UUID data type support |
Original file line number Diff line number Diff line change @@ -353,7 +353,7 @@ where
353353}
354354
355355#[ wrappers_fdw(
356- version = "0.1.8 " ,
356+ version = "0.1.9 " ,
357357 author = "Supabase" ,
358358 website = "https://github.com/supabase/wrappers/tree/main/wrappers/src/fdw/clickhouse_fdw" ,
359359 error_type = "ClickHouseFdwError"
@@ -584,8 +584,17 @@ impl ForeignDataWrapper<ClickHouseFdwError> for ClickHouseFdw {
584584 self . is_scan_complete = false ;
585585 self . current_row_data = None ;
586586
587+ // get stream buffer size from options, with validation
588+ let stream_buffer_size = options
589+ . get ( "stream_buffer_size" )
590+ . map ( |s| s. parse :: < usize > ( ) . map ( |size| size. clamp ( 1 , 100_000 ) ) )
591+ . transpose ( )
592+ . map_err ( ClickHouseFdwError :: ParseIntError ) ?
593+ . unwrap_or ( 1024 ) ;
594+
587595 // create bounded channel
588- let ( tx, rx) = channel:: bounded :: < ClickHouseFdwResult < Option < ConvertedRow > > > ( 1024 ) ;
596+ let ( tx, rx) =
597+ channel:: bounded :: < ClickHouseFdwResult < Option < ConvertedRow > > > ( stream_buffer_size) ;
589598 self . row_receiver = Some ( rx) ;
590599
591600 // clone data needed by the async task
Original file line number Diff line number Diff line change @@ -85,7 +85,8 @@ mod tests {
8585 SERVER my_clickhouse_server
8686 OPTIONS (
8787 table 'test_table',
88- rowid_column 'id'
88+ rowid_column 'id',
89+ stream_buffer_size '512'
8990 )
9091 "# ,
9192 None ,
You can’t perform that action at this time.
0 commit comments