Skip to content

Commit 7f66725

Browse files
Disable alter command for external table / stream (#1019)
Co-authored-by: Alan Yu <[email protected]>
1 parent 1d1b555 commit 7f66725

File tree

5 files changed

+23
-6
lines changed

5 files changed

+23
-6
lines changed

src/Databases/ApacheIceberg/DatabaseIceberg.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ StoragePtr DatabaseApacheIceberg::tryGetTable(const String & name [[maybe_unused
261261
/*table_id_=*/StorageID{getDatabaseName(), name},
262262
context_,
263263
ColumnsDescription(table_metadata.getSchema()),
264+
/*schema_version=*/1,
264265
/*comment=*/"",
265266
&stream_storage,
266267
/*attach=*/false);

src/Storages/ExternalStream/StorageExternalStream.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#include <Storages/ExternalStream/StorageExternalStream.h>
22

33
#include <IO/Kafka/Connection.h>
4+
#include <IO/ReadBufferFromFile.h>
5+
#include <IO/ReadHelpers.h>
6+
#include <IO/WriteBufferFromFile.h>
7+
#include <IO/WriteHelpers.h>
48
#include <Interpreters/Context.h>
59
#include <Interpreters/ExpressionAnalyzer.h>
610
#include <Parsers/ASTCreateQuery.h>
@@ -20,11 +24,6 @@
2024
#include <Storages/SelectQueryInfo.h>
2125
#include <Storages/StorageFactory.h>
2226

23-
#include <IO/ReadBufferFromFile.h>
24-
#include <IO/ReadHelpers.h>
25-
#include <IO/WriteBufferFromFile.h>
26-
#include <IO/WriteHelpers.h>
27-
2827
#include <Poco/Net/AcceptCertificateHandler.h>
2928
#include <Poco/Net/KeyFileHandler.h>
3029
#include <Poco/Net/SSLManager.h>
@@ -238,6 +237,7 @@ StorageExternalStream::StorageExternalStream(
238237
const StorageID & table_id_,
239238
ContextPtr context_,
240239
const ColumnsDescription & columns_,
240+
Int32 schema_version,
241241
const String & comment,
242242
ASTStorage * storage_def,
243243
bool attach)
@@ -253,6 +253,7 @@ StorageExternalStream::StorageExternalStream(
253253
ColumnsDescription columns = initColumnsDescription(columns_, *external_stream_settings, context_);
254254

255255
StorageInMemoryMetadata storage_metadata;
256+
storage_metadata.setVersion(schema_version);
256257
storage_metadata.setComment(comment);
257258
if (storage_def->partition_by != nullptr)
258259
{
@@ -290,6 +291,11 @@ void StorageExternalStream::read(
290291
getNested()->read(query_plan, column_names, storage_snapshot, query_info, context_, processed_stage, max_block_size, num_streams);
291292
}
292293

294+
void StorageExternalStream::alter(const AlterCommands &, ContextPtr, AlterLockHolder &)
295+
{
296+
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Alter command is not supported for external stream yet");
297+
}
298+
293299
void registerStorageExternalStream(StorageFactory & factory)
294300
{
295301
/** * ExternalStream engine arguments : ExternalStream(shard_by_expr)
@@ -300,7 +306,7 @@ void registerStorageExternalStream(StorageFactory & factory)
300306

301307
if (args.storage_def->settings != nullptr)
302308
return StorageExternalStream::create(
303-
args.engine_args, args.table_id, args.getContext(), args.columns, args.comment, args.storage_def, args.attach);
309+
args.engine_args, args.table_id, args.getContext(), args.columns, args.schema_version, args.comment, args.storage_def, args.attach);
304310
else
305311
throw Exception(ErrorCodes::BAD_ARGUMENTS, "External stream requires correct settings setup");
306312
};

src/Storages/ExternalStream/StorageExternalStream.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,15 @@ class StorageExternalStream final : public shared_ptr_helper<StorageExternalStre
6666

6767
std::optional<String> preferredColumn() const override { return external_stream->preferredColumn(); }
6868

69+
void alter(const AlterCommands & commands, ContextPtr context, AlterLockHolder & alter_lock_holder) override;
70+
6971
protected:
7072
StorageExternalStream(
7173
const ASTs & engine_args,
7274
const StorageID & table_id_,
7375
ContextPtr context_,
7476
const ColumnsDescription & columns_,
77+
Int32 schema_version,
7578
const String & comment,
7679
ASTStorage * storage_def,
7780
bool attach);

src/Storages/ExternalTable/ExternalTableFactory.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ StoragePtr ExternalTableFactory::getExternalTable(const StorageFactory::Argument
7777
}
7878
}
7979

80+
storage_metadata.setVersion(args.schema_version);
81+
8082
return creators.at(type)(args.table_id, storage_metadata, std::move(external_table_settings), args.attach, context);
8183
}
8284

src/Storages/ExternalTable/StorageExternalTable.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ class StorageExternalTable : public IStorage, public WithContext, public shared_
4747

4848
void updateTableSchema(bool retry_in_background);
4949

50+
void alter(const AlterCommands &, ContextPtr, AlterLockHolder &) override
51+
{
52+
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Alter command is not supported for external table yet");
53+
}
54+
5055
protected:
5156
StorageExternalTable(
5257
const StorageID & table_id,

0 commit comments

Comments
 (0)