Package: target-duckdb
target-duckdbSingertarget that loads data into DuckDB following theSinger spec.InstallFirst, make sure Python 3 is installed on your system or follow these
installation instructions forMacorUbuntu.It's recommended to use a virtualenv:makevenvTo runLike any other target that's following the singer specification:some-singer-tap | target-duckdb --config [config.json]It's reading incoming messages from STDIN and using the properties inconfig.jsonto load data into DuckDB.Note: To avoid version conflicts runtapandtargetsin separate virtual environments.Configuration settingsRunning the target connector requires aconfig.jsonfile. An example with the minimal settings:{"path":"/path/to/local/file.duckdb","default_target_schema":"main"}Additional options inconfig.json:PropertyTypeRequired?Descriptionpath (alias: filepath)StringYesThe path to use for theduckdb.connectcall; either a local file or a MotherDuck connection uri.dbname (alias: database)StringThe database name to write to; this will be inferred from the path property if it is not specified.tokenStringFor MotherDuck connections, the auth token to use (this may also be set directly via the MOTHERDUCK_TOKEN environment variable.delimiterString(Default: ',') The delimiter to use for the CSV files that are used for record imports.quotecharString(Default: '"') The quote character to use for the CSV files that are used for record imports.batch_size_rowsInteger(Default: 100000) Maximum number of rows in each batch. At the end of each batch, the rows in the batch are loaded into DuckDB.flush_all_streamsBoolean(Default: False) Flush and load every stream into DuckDB when one batch is full. Warning: This may trigger the COPY command to use files with low number of records.default_target_schemaStringName of the schema where the tables will be created. Ifschema_mappingis not defined then every stream sent by the tap is loaded into this schema.schema_mappingObjectUseful if you want to load multiple streams from one tap to multiple DuckDB schemas.If the tap sends thestream_idin<schema_name>-<table_name>format then this option overwrites thedefault_target_schemavalue.add_metadata_columnsBoolean(Default: False) Metadata columns add extra row level information about data ingestions, (i.e. when was the row read in source, when was inserted or deleted in postgres etc.) Metadata columns are creating automatically by adding extra columns to the tables with a column prefix_SDC_. The column names are following the stitch naming conventions documented athttps://www.stitchdata.com/docs/data-structure/integration-schemas#sdc-columns. Enabling metadata columns will flag the deleted rows by setting the_SDC_DELETED_ATmetadata column. Without theadd_metadata_columnsoption the deleted rows from singer taps will not be recognisable in DuckDB.hard_deleteBoolean(Default: False) Whenhard_deleteoption is true then DELETE SQL commands will be performed in DuckDB to delete rows in tables. It's achieved by continuously checking the_SDC_DELETED_ATmetadata column sent by the singer tap. Due to deleting rows requires metadata columns,hard_deleteoption automatically enables theadd_metadata_columnsoption as well.data_flattening_max_levelInteger(Default: 0) Object type RECORD items from taps can be transformed to flattened columns by creating columns automatically.When value is 0 (default) then flattening functionality is turned off.primary_key_requiredBoolean(Default: True) Log based and Incremental replications on tables with no Primary Key cause duplicates when merging UPDATE events. When set to true, stop loading data if no Primary Key is defined.validate_recordsBoolean(Default: False) Validate every single record message to the corresponding JSON schema. This option is disabled by default and invalid RECORD messages will fail only at load time by DuckDB. Enabling this option will detect invalid records earlier but could cause performance degradation.temp_dirString(Default: platform-dependent) Directory of temporary CSV files with RECORD messages.To run tests:Install python dependencies in a virtual env and run unit and integration testsmake venvTo run unit tests:make unit_testTo run integration tests:make integration_testTo run pylint:Install python dependencies and run python lintermake venv pylintLicenseApache License Version 2.0SeeLICENSEto see the full text.