Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for optional field presence before using them #47

Merged
merged 3 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions includes/motherduck_destination_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ static constexpr const char *const CONFIG_TEST_NAME_AUTHENTICATE =
static constexpr const char *const CONFIG_TEST_NAME_CSV_BLOCK_SIZE =
"test_csv_block_size";

static const int DUCKDB_DEFAULT_PRECISION = 18;

static const int DUCKDB_DEFAULT_SCALE = 3;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this should probably be in the cpp file. Otherwise we'll actually have multiple copies of these constants in every cpp file that includes this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't #pragma once prevent that?


class DestinationSdkImpl final : public fivetran_sdk::Destination::Service {
public:
DestinationSdkImpl() = default;
Expand Down
8 changes: 5 additions & 3 deletions src/motherduck_destination_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ std::vector<column_def> get_duckdb_columns(
DataType_Name(col.type()) + "> for column <" +
col.name() + "> to a DuckDB type");
}
auto precision = col.has_decimal() ? col.decimal().precision() : DUCKDB_DEFAULT_PRECISION;
auto scale = col.has_decimal() ? col.decimal().scale() : DUCKDB_DEFAULT_SCALE;
duckdb_columns.push_back(column_def{col.name(), ddbtype, col.primary_key(),
col.decimal().precision(),
col.decimal().scale()});
precision, scale});
}
return duckdb_columns;
}
Expand Down Expand Up @@ -310,8 +311,9 @@ DestinationSdkImpl::Truncate(::grpc::ServerContext *context,
std::chrono::nanoseconds delete_before_ts =
std::chrono::seconds(request->utc_delete_before().seconds()) +
std::chrono::nanoseconds(request->utc_delete_before().nanos());
const std::string deleted_column = request->has_soft() ? request->soft().deleted_column() : "";
truncate_table(*con, table_name, request->synced_column(),
delete_before_ts, request->soft().deleted_column());
delete_before_ts, deleted_column);
} else {
mdlog::warning("Table <" + request->table_name() +
"> not found in schema <" + request->schema_name() +
Expand Down
Loading