From 23a33f2cccb17482f25daa3cd484a2faeb36dc51 Mon Sep 17 00:00:00 2001 From: auxten Date: Mon, 12 Jun 2023 10:52:15 +0000 Subject: [PATCH 1/2] Check memoryview size before using --- chdb/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chdb/__init__.py b/chdb/__init__.py index d6d9cc6ae29..f56f0652179 100644 --- a/chdb/__init__.py +++ b/chdb/__init__.py @@ -35,7 +35,8 @@ def to_arrowTable(res): print(f'ImportError: {e}') print('Please install pyarrow and pandas via "pip install pyarrow pandas"') raise ImportError('Failed to import pyarrow or pandas') from None - + if len(res.get_memview()) == 0: + return pa.Table.from_batches([], schema=pa.schema([])) return pa.RecordBatchFileReader(res.get_memview()).read_all() From 9f590813b1f6225eebeed885aeb311208277d592 Mon Sep 17 00:00:00 2001 From: auxten Date: Thu, 15 Jun 2023 10:55:33 +0000 Subject: [PATCH 2/2] Check format is supported before the engine runs too far --- programs/local/LocalServer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/programs/local/LocalServer.cpp b/programs/local/LocalServer.cpp index 4b2c59f499d..f96cd9d21c4 100644 --- a/programs/local/LocalServer.cpp +++ b/programs/local/LocalServer.cpp @@ -61,6 +61,7 @@ namespace DB namespace ErrorCodes { extern const int BAD_ARGUMENTS; + extern const int UNKNOWN_FORMAT; extern const int CANNOT_LOAD_CONFIG; extern const int FILE_ALREADY_EXISTS; } @@ -557,6 +558,11 @@ void LocalServer::processConfig() global_context->setMacros(std::make_unique(config(), "macros", log)); format = config().getString("output-format", config().getString("format", is_interactive ? "PrettyCompact" : "TSV")); + + /// Check format is supported before the engine runs too far + if (!FormatFactory::instance().isOutputFormat(format)) + throw Exception(ErrorCodes::UNKNOWN_FORMAT, "Unknown output format {}", format); + insert_format = "Values"; /// Setting value from cmd arg overrides one from config