本文簡要介紹 python 語言中 pyflink.table.StatementSet.add_insert
的用法。
用法:
add_insert(target_path_or_descriptor: Union[str, pyflink.table.table_descriptor.TableDescriptor], table, overwrite: bool = False) → pyflink.table.statement_set.StatementSet
添加一條語句,將給定 Table 對象定義的管道應寫入在指定路徑下注冊或通過給定 TableDescriptor 表示的表(由 DynamicTableSink 支持)。
當target_path_or_descriptor 是故事路徑時:
有關路徑解析的規則,請參閱
use_database()
或use_catalog()
的文檔。當target_path_or_descriptor 是表說明符時:
給定的 TableDescriptor 注冊為內聯(即匿名)臨時目錄表(請參閱
create_temporary_table()
)。然後將一條語句添加到將 Table 對象的管道插入該臨時表的語句集中。
此方法允許為接收器說明符聲明一個模式。該聲明類似於 SQL 中的 {@code CREATE TABLE} DDL,並允許:
使用自定義 DataType 覆蓋自動派生列
在物理列旁邊添加元數據列
聲明一個主鍵
可以聲明沒有物理/常規列的模式。在這種情況下,這些列將自動派生並隱式放置在模式聲明的開頭。
例子:
>>> stmt_set = table_env.create_statement_set() >>> source_table = table_env.from_path("SourceTable") >>> sink_descriptor = TableDescriptor.for_connector("blackhole") \ ... .schema(Schema.new_builder() ... .build()) \ ... .build() >>> stmt_set.add_insert(sink_descriptor, source_table)
注意
表說明符的add_insert(案例 2.)是從 flink 1.14.0 添加的。
參數:
target_path_or_descriptor- 注冊路徑
TableSink
或說明應插入數據的接收器表的說明符Table
是寫的。table(
pyflink.table.Table
) - 要添加的表。overwrite- 指示插入是否應覆蓋現有數據。
返回:
當前StatementSet 實例。
版本 1.11.0 中的新函數。
相關用法
- Python pyflink StreamTableEnvironment.from_data_stream用法及代碼示例
- Python pyflink StreamTableEnvironment.create用法及代碼示例
- Python pyflink StreamExecutionEnvironment.set_restart_strategy用法及代碼示例
- Python pyflink StreamExecutionEnvironment.set_python_executable用法及代碼示例
- Python pyflink StreamExecutionEnvironment.enable_checkpointing用法及代碼示例
- Python pyflink StreamTableEnvironment.to_changelog_stream用法及代碼示例
- Python pyflink StreamExecutionEnvironment.set_state_backend用法及代碼示例
- Python pyflink StreamExecutionEnvironment.add_python_archive用法及代碼示例
- Python pyflink StreamExecutionEnvironment.set_stream_time_characteristic用法及代碼示例
- Python pyflink StreamExecutionEnvironment.register_type用法及代碼示例
- Python pyflink StreamExecutionEnvironment.set_default_savepoint_directory用法及代碼示例
- Python pyflink StreamExecutionEnvironment.add_default_kryo_serializer用法及代碼示例
- Python pyflink StreamExecutionEnvironment.set_python_requirements用法及代碼示例
- Python pyflink StreamExecutionEnvironment.register_type_with_kryo_serializer用法及代碼示例
- Python pyflink Session用法及代碼示例
- Python pyflink Slide用法及代碼示例
- Python pyflink Schema.Builder.watermark用法及代碼示例
- Python pyflink Schema.Builder.column_by_expression用法及代碼示例
- Python pyflink SlidingProcessingTimeWindows用法及代碼示例
- Python pyflink SlidingEventTimeWindows用法及代碼示例
- Python pyflink Table.intersect_all用法及代碼示例
- Python pyflink GroupedTable.select用法及代碼示例
- Python pyflink Expression.to_date用法及代碼示例
- Python pyflink Table.fetch用法及代碼示例
- Python pyflink PulsarSourceBuilder用法及代碼示例
注:本文由純淨天空篩選整理自apache.org大神的英文原創作品 pyflink.table.StatementSet.add_insert。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。