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

Add .clang-format file and reformat all files #40

Merged
merged 6 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
BasedOnStyle: Google
ColumnLimit: 90
IncludeBlocks: Preserve
ReflowComments: false
SortIncludes: false
3 changes: 2 additions & 1 deletion scripts/test_flight_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ def main():
with flight_sql.connect(uri="grpc+tls://localhost:31337",
db_kwargs={"username": "flight_username",
"password": flight_password,
DatabaseOptions.TLS_SKIP_VERIFY.value: "true" # Not needed if you use a trusted CA-signed TLS cert
# Not needed if you use a trusted CA-signed TLS cert
DatabaseOptions.TLS_SKIP_VERIFY.value: "true"
}
) as conn:
with conn.cursor() as cur:
Expand Down
1,527 changes: 759 additions & 768 deletions src/duckdb/duckdb_server.cpp

Large diffs are not rendered by default.

177 changes: 88 additions & 89 deletions src/duckdb/duckdb_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,133 +26,132 @@
#include <arrow/flight/sql/server.h>

namespace arrow {
namespace flight {
namespace sql {
namespace duckdbflight {
namespace flight {
namespace sql {
namespace duckdbflight {

/// \brief Convert a column type to a ArrowType.
/// \param duckdb_type the duckdb type.
/// \return The equivalent ArrowType.
std::shared_ptr<DataType> GetArrowType(const char *duckdb_type);
std::shared_ptr<DataType> GetArrowType(const char *duckdb_type);

/// \brief Example implementation of FlightSqlServerBase backed by an in-memory DuckDB
/// database.
class DuckDBFlightSqlServer : public FlightSqlServerBase {
public:
~DuckDBFlightSqlServer() override;
class DuckDBFlightSqlServer : public FlightSqlServerBase {
public:
~DuckDBFlightSqlServer() override;

static arrow::Result<std::shared_ptr<DuckDBFlightSqlServer>> Create(const std::string &path,
const duckdb::DBConfig &config,
const bool &print_queries);
static arrow::Result<std::shared_ptr<DuckDBFlightSqlServer>> Create(
const std::string &path, const duckdb::DBConfig &config, const bool &print_queries);

/// \brief Auxiliary method used to execute an arbitrary SQL statement on the underlying
/// SQLite database.
Status ExecuteSql(const std::string &sql);
/// \brief Auxiliary method used to execute an arbitrary SQL statement on the underlying
/// SQLite database.
Status ExecuteSql(const std::string &sql);

arrow::Result<std::unique_ptr<FlightInfo>> GetFlightInfoStatement(
const ServerCallContext &context, const StatementQuery &command,
const FlightDescriptor &descriptor) override;
arrow::Result<std::unique_ptr<FlightInfo>> GetFlightInfoStatement(
const ServerCallContext &context, const StatementQuery &command,
const FlightDescriptor &descriptor) override;

arrow::Result<std::unique_ptr<FlightDataStream>> DoGetStatement(
const ServerCallContext &context, const StatementQueryTicket &command) override;
arrow::Result<std::unique_ptr<FlightDataStream>> DoGetStatement(
const ServerCallContext &context, const StatementQueryTicket &command) override;

arrow::Result<std::unique_ptr<FlightInfo>> GetFlightInfoCatalogs(
const ServerCallContext &context, const FlightDescriptor &descriptor) override;
arrow::Result<std::unique_ptr<FlightInfo>> GetFlightInfoCatalogs(
const ServerCallContext &context, const FlightDescriptor &descriptor) override;

arrow::Result<std::unique_ptr<FlightDataStream>> DoGetCatalogs(
const ServerCallContext &context) override;
arrow::Result<std::unique_ptr<FlightDataStream>> DoGetCatalogs(
const ServerCallContext &context) override;

arrow::Result<std::unique_ptr<FlightInfo>> GetFlightInfoSchemas(
const ServerCallContext &context, const GetDbSchemas &command,
const FlightDescriptor &descriptor) override;
arrow::Result<std::unique_ptr<FlightInfo>> GetFlightInfoSchemas(
const ServerCallContext &context, const GetDbSchemas &command,
const FlightDescriptor &descriptor) override;

arrow::Result<std::unique_ptr<FlightDataStream>> DoGetDbSchemas(
const ServerCallContext &context, const GetDbSchemas &command) override;
arrow::Result<std::unique_ptr<FlightDataStream>> DoGetDbSchemas(
const ServerCallContext &context, const GetDbSchemas &command) override;

arrow::Result<int64_t> DoPutCommandStatementUpdate(
const ServerCallContext &context, const StatementUpdate &update) override;
arrow::Result<int64_t> DoPutCommandStatementUpdate(
const ServerCallContext &context, const StatementUpdate &update) override;

arrow::Result<ActionCreatePreparedStatementResult> CreatePreparedStatement(
const ServerCallContext &context,
const ActionCreatePreparedStatementRequest &request) override;
arrow::Result<ActionCreatePreparedStatementResult> CreatePreparedStatement(
const ServerCallContext &context,
const ActionCreatePreparedStatementRequest &request) override;

Status ClosePreparedStatement(
const ServerCallContext &context,
const ActionClosePreparedStatementRequest &request) override;
Status ClosePreparedStatement(
const ServerCallContext &context,
const ActionClosePreparedStatementRequest &request) override;

arrow::Result<std::unique_ptr<FlightInfo>> GetFlightInfoPreparedStatement(
const ServerCallContext &context, const PreparedStatementQuery &command,
const FlightDescriptor &descriptor) override;
arrow::Result<std::unique_ptr<FlightInfo>> GetFlightInfoPreparedStatement(
const ServerCallContext &context, const PreparedStatementQuery &command,
const FlightDescriptor &descriptor) override;

arrow::Result<std::unique_ptr<FlightDataStream>> DoGetPreparedStatement(
const ServerCallContext &context, const PreparedStatementQuery &command) override;
arrow::Result<std::unique_ptr<FlightDataStream>> DoGetPreparedStatement(
const ServerCallContext &context, const PreparedStatementQuery &command) override;

Status DoPutPreparedStatementQuery(const ServerCallContext &context,
const PreparedStatementQuery &command,
FlightMessageReader *reader,
FlightMetadataWriter *writer) override;
Status DoPutPreparedStatementQuery(const ServerCallContext &context,
const PreparedStatementQuery &command,
FlightMessageReader *reader,
FlightMetadataWriter *writer) override;

arrow::Result<int64_t> DoPutPreparedStatementUpdate(
const ServerCallContext &context, const PreparedStatementUpdate &command,
FlightMessageReader *reader) override;
arrow::Result<int64_t> DoPutPreparedStatementUpdate(
const ServerCallContext &context, const PreparedStatementUpdate &command,
FlightMessageReader *reader) override;

arrow::Result<std::unique_ptr<FlightInfo>> GetFlightInfoTables(
const ServerCallContext &context, const GetTables &command,
const FlightDescriptor &descriptor) override;
arrow::Result<std::unique_ptr<FlightInfo>> GetFlightInfoTables(
const ServerCallContext &context, const GetTables &command,
const FlightDescriptor &descriptor) override;

arrow::Result<std::unique_ptr<FlightDataStream>> DoGetTables(
const ServerCallContext &context, const GetTables &command) override;
arrow::Result<std::unique_ptr<FlightDataStream>> DoGetTables(
const ServerCallContext &context, const GetTables &command) override;

arrow::Result<std::unique_ptr<FlightInfo>> GetFlightInfoTableTypes(
const ServerCallContext &context, const FlightDescriptor &descriptor) override;
arrow::Result<std::unique_ptr<FlightInfo>> GetFlightInfoTableTypes(
const ServerCallContext &context, const FlightDescriptor &descriptor) override;

arrow::Result<std::unique_ptr<FlightDataStream>> DoGetTableTypes(
const ServerCallContext &context) override;
arrow::Result<std::unique_ptr<FlightDataStream>> DoGetTableTypes(
const ServerCallContext &context) override;

arrow::Result<std::unique_ptr<FlightInfo>> GetFlightInfoImportedKeys(
const ServerCallContext &context, const GetImportedKeys &command,
const FlightDescriptor &descriptor) override;
arrow::Result<std::unique_ptr<FlightInfo>> GetFlightInfoImportedKeys(
const ServerCallContext &context, const GetImportedKeys &command,
const FlightDescriptor &descriptor) override;

arrow::Result<std::unique_ptr<FlightDataStream>> DoGetImportedKeys(
const ServerCallContext &context, const GetImportedKeys &command) override;
arrow::Result<std::unique_ptr<FlightDataStream>> DoGetImportedKeys(
const ServerCallContext &context, const GetImportedKeys &command) override;

arrow::Result<std::unique_ptr<FlightInfo>> GetFlightInfoExportedKeys(
const ServerCallContext &context, const GetExportedKeys &command,
const FlightDescriptor &descriptor) override;
arrow::Result<std::unique_ptr<FlightInfo>> GetFlightInfoExportedKeys(
const ServerCallContext &context, const GetExportedKeys &command,
const FlightDescriptor &descriptor) override;

arrow::Result<std::unique_ptr<FlightDataStream>> DoGetExportedKeys(
const ServerCallContext &context, const GetExportedKeys &command) override;
arrow::Result<std::unique_ptr<FlightDataStream>> DoGetExportedKeys(
const ServerCallContext &context, const GetExportedKeys &command) override;

arrow::Result<std::unique_ptr<FlightInfo>> GetFlightInfoCrossReference(
const ServerCallContext &context, const GetCrossReference &command,
const FlightDescriptor &descriptor) override;
arrow::Result<std::unique_ptr<FlightInfo>> GetFlightInfoCrossReference(
const ServerCallContext &context, const GetCrossReference &command,
const FlightDescriptor &descriptor) override;

arrow::Result<std::unique_ptr<FlightDataStream>> DoGetCrossReference(
const ServerCallContext &context, const GetCrossReference &command) override;
arrow::Result<std::unique_ptr<FlightDataStream>> DoGetCrossReference(
const ServerCallContext &context, const GetCrossReference &command) override;

arrow::Result<std::unique_ptr<FlightInfo>> GetFlightInfoPrimaryKeys(
const ServerCallContext &context, const GetPrimaryKeys &command,
const FlightDescriptor &descriptor) override;
arrow::Result<std::unique_ptr<FlightInfo>> GetFlightInfoPrimaryKeys(
const ServerCallContext &context, const GetPrimaryKeys &command,
const FlightDescriptor &descriptor) override;

arrow::Result<std::unique_ptr<FlightDataStream>> DoGetPrimaryKeys(
const ServerCallContext &context, const GetPrimaryKeys &command) override;
arrow::Result<std::unique_ptr<FlightDataStream>> DoGetPrimaryKeys(
const ServerCallContext &context, const GetPrimaryKeys &command) override;

arrow::Result<ActionBeginTransactionResult> BeginTransaction(
const ServerCallContext &context,
const ActionBeginTransactionRequest &request) override;
arrow::Result<ActionBeginTransactionResult> BeginTransaction(
const ServerCallContext &context,
const ActionBeginTransactionRequest &request) override;

Status EndTransaction(const ServerCallContext &context,
const ActionEndTransactionRequest &request) override;
Status EndTransaction(const ServerCallContext &context,
const ActionEndTransactionRequest &request) override;

private:
class Impl;
private:
class Impl;

std::shared_ptr<Impl> impl_;
std::shared_ptr<Impl> impl_;

explicit DuckDBFlightSqlServer(std::shared_ptr<Impl> impl);
};
explicit DuckDBFlightSqlServer(std::shared_ptr<Impl> impl);
};

} // namespace duckdbflight
} // namespace sql
} // namespace flight
} // namespace duckdbflight
} // namespace sql
} // namespace flight
} // namespace arrow
4 changes: 3 additions & 1 deletion src/duckdb/duckdb_sql_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace flight {
namespace sql {
namespace duckdbflight {

// clang-format off
/// \brief Gets the mapping from SQL info ids to SqlInfoResult instances.
/// \return the cache.
SqlInfoResultMap GetSqlInfoResultMap() {
Expand Down Expand Up @@ -643,8 +644,9 @@ SqlInfoResultMap GetSqlInfoResultMap() {
std::vector<int32_t>(
{SqlInfoOptions::SqlSupportsConvert::SQL_CONVERT_INTEGER})}}))}};
}
// clang-format on

} // namespace sqlite
} // namespace duckdbflight
} // namespace sql
} // namespace flight
} // namespace arrow
2 changes: 1 addition & 1 deletion src/duckdb/duckdb_sql_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace duckdbflight {
/// \return the cache.
SqlInfoResultMap GetSqlInfoResultMap();

} // namespace sqlite
} // namespace duckdbflight
} // namespace sql
} // namespace flight
} // namespace arrow
Loading
Loading