This commit is contained in:
Amos Bird 2021-07-31 15:50:16 +08:00
parent 479d4fa991
commit c03b20d1a1
No known key found for this signature in database
GPG Key ID: 80D430DCBECFEDB4
3 changed files with 12 additions and 5 deletions

View File

@ -19,10 +19,10 @@ public:
static constexpr auto name = "timezone";
static FunctionPtr create(ContextPtr context)
{
return std::make_shared<FunctionTimezone>(context);
return std::make_shared<FunctionTimezone>(context->isDistributed());
}
explicit FunctionTimezone(ContextPtr context_) : context(context_)
explicit FunctionTimezone(bool is_distributed_) : is_distributed(is_distributed_)
{
}
@ -42,14 +42,14 @@ public:
bool isDeterministic() const override { return false; }
bool isDeterministicInScopeOfQuery() const override { return true; }
bool isSuitableForConstantFolding() const override { return !context->isDistributed(); }
bool isSuitableForConstantFolding() const override { return !is_distributed; }
ColumnPtr executeImpl(const ColumnsWithTypeAndName &, const DataTypePtr &, size_t input_rows_count) const override
{
return DataTypeString().createColumnConst(input_rows_count, DateLUT::instance().getTimeZone());
}
private:
ContextPtr context;
bool is_distributed;
};
}

View File

@ -46,7 +46,7 @@ struct SelectQueryOptions
bool is_subquery = false; // non-subquery can also have subquery_depth > 0, e.g. insert select
bool with_all_cols = false; /// asterisk include materialized and aliased columns
/// These two fields are used to evaluate getShardNum() and getShardCount() function when
/// These two fields are used to evaluate shardNum() and shardCount() function when
/// prefer_localhost_replica == 1 and local instance is selected. They are needed because local
/// instance might have multiple shards and scalars can only hold one value.
std::optional<UInt32> shard_num;

View File

@ -0,0 +1,7 @@
0 0
1 3
2 3
3 3
1 3
2 3
3 3