Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into iot-3
Browse files Browse the repository at this point in the history
  • Loading branch information
vagetablechicken committed Jun 27, 2024
2 parents 3201154 + 25bd745 commit af99041
Show file tree
Hide file tree
Showing 44 changed files with 1,536 additions and 170 deletions.
111 changes: 111 additions & 0 deletions cases/query/udf_query.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,25 @@ cases:
data: |
true, true, false, false, true, false, true, false, true, false, true
- id: isin
mode: request-unsupport
inputs:
- name: t1
columns: ["col1:int32", "std_ts:timestamp", "col2:string"]
indexs: ["index1:col1:std_ts"]
rows:
- [1, 1590115420001, "ABCabcabc"]
sql: |
select
isin(2, [2,2]) as c0,
isin(cast(3 as int64), ARRAY<INT64>[NULL, 1, 2]) as c1
expect:
columns:
- c0 bool
- c1 bool
data: |
true, false
- id: array_split
mode: request-unsupport
inputs:
Expand All @@ -554,6 +573,98 @@ cases:
- c1 bool
data: |
true, false
- id: array_join
mode: request-unsupport
sql: |
select
array_join(["1", "2"], ",") c1,
array_join(["1", "2"], "") c2,
array_join(["1", "2"], cast(null as string)) c3,
array_join(["1", NULL, "4", "5", NULL], "-") c4,
array_join(array<string>[], ",") as c5
expect:
columns:
- c1 string
- c2 string
- c3 string
- c4 string
- c5 string
rows:
- ["1,2", "12", "12", "1-4-5", ""]
- id: array_combine
mode: request-unsupport
sql: |
select
array_join(array_combine("-", ["1", "2"], ["3", "4"]), ",") c0,
expect:
columns:
- c0 string
rows:
- ["1-3,1-4,2-3,2-4"]

- id: array_combine_2
desc: array_combine casting array to array<string> first
mode: request-unsupport
sql: |
select
array_join(array_combine("-", [1, 2], [3, 4]), ",") c0,
array_join(array_combine("-", [1, 2], array<int64>[3], ["5", "6"]), ",") c1,
array_join(array_combine("|", ["1"], [timestamp(1717171200000), timestamp("2024-06-02 12:00:00")]), ",") c2,
array_join(array_combine("|", ["1"]), ",") c3,
expect:
columns:
- c0 string
- c1 string
- c2 string
- c3 string
rows:
- ["1-3,1-4,2-3,2-4", "1-3-5,1-3-6,2-3-5,2-3-6", "1|2024-06-01 00:00:00,1|2024-06-02 12:00:00", "1"]
- id: array_combine_3
desc: null values skipped
mode: request-unsupport
sql: |
select
array_join(array_combine("-", [1, NULL], [3, 4]), ",") c0,
array_join(array_combine("-", ARRAY<INT>[NULL], ["9", "8"]), ",") c1,
array_join(array_combine(string(NULL), ARRAY<INT>[1], ["9", "8"]), ",") c2,
expect:
columns:
- c0 string
- c1 string
- c2 string
rows:
- ["1-3,1-4", "", "19,18"]
- id: array_combine_4
desc: construct array from table
mode: request-unsupport
inputs:
- name: t1
columns: ["col1:int32", "std_ts:timestamp", "col2:string"]
indexs: ["index1:col1:std_ts"]
rows:
- [1, 1590115420001, "foo"]
- [2, 1590115420001, "bar"]
sql: |
select
col1,
array_join(array_combine("-", [col1, 10], [col2, "c2"]), ",") c0,
from t1
expect:
columns:
- col1 int32
- c0 string
rows:
- [1, "1-foo,1-c2,10-foo,10-c2"]
- [2, "2-bar,2-c2,10-bar,10-c2"]
- id: array_combine_err1
mode: request-unsupport
sql: |
select
array_join(array_combine("-"), ",") c0,
expect:
success: false
msg: |
Fail to resolve expression: array_join(array_combine(-), ,)
# ================================================================
# Map data type
Expand Down
16 changes: 8 additions & 8 deletions docs/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions extensions/kafka-connect-jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@
</scm>

<properties>
<derby.version>10.14.2.0</derby.version>
<derby.version>10.17.1.0</derby.version>
<commons-io.version>2.7</commons-io.version>
<kafka.connect.maven.plugin.version>0.11.1</kafka.connect.maven.plugin.version>
<sqlite-jdbc.version>3.41.2.2</sqlite-jdbc.version>
<oracle.jdbc.driver.version>19.7.0.0</oracle.jdbc.driver.version>
<mssqlserver.jdbc.driver.version>8.4.1.jre8</mssqlserver.jdbc.driver.version>
<postgresql.version>42.3.3</postgresql.version>
<postgresql.version>42.3.9</postgresql.version>
<jtds.driver.version>1.3.1</jtds.driver.version>
<openmldb-jdbc.version>0.8.5</openmldb-jdbc.version>
<licenses.name>Confluent Community License</licenses.name>
Expand Down
4 changes: 4 additions & 0 deletions hybridse/include/node/node_enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ enum SqlNodeType {
kColumnSchema,
kCreateUserStmt,
kAlterUserStmt,
kGrantStmt,
kRevokeStmt,
kCallStmt,
kSqlNodeTypeLast, // debug type
kVariadicUdfDef,
Expand Down Expand Up @@ -347,6 +349,8 @@ enum PlanType {
kPlanTypeShow,
kPlanTypeCreateUser,
kPlanTypeAlterUser,
kPlanTypeGrant,
kPlanTypeRevoke,
kPlanTypeCallStmt,
kUnknowPlan = -1,
};
Expand Down
61 changes: 61 additions & 0 deletions hybridse/include/node/plan_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,67 @@ class CreateUserPlanNode : public LeafPlanNode {
const std::shared_ptr<OptionsMap> options_;
};

class GrantPlanNode : public LeafPlanNode {
public:
explicit GrantPlanNode(std::optional<std::string> target_type, std::string database, std::string target,
std::vector<std::string> privileges, bool is_all_privileges,
std::vector<std::string> grantees, bool with_grant_option)
: LeafPlanNode(kPlanTypeGrant),
target_type_(target_type),
database_(database),
target_(target),
privileges_(privileges),
is_all_privileges_(is_all_privileges),
grantees_(grantees),
with_grant_option_(with_grant_option) {}
~GrantPlanNode() = default;
const std::vector<std::string> Privileges() const { return privileges_; }
const std::vector<std::string> Grantees() const { return grantees_; }
const std::string Database() const { return database_; }
const std::string Target() const { return target_; }
const std::optional<std::string> TargetType() const { return target_type_; }
const bool IsAllPrivileges() const { return is_all_privileges_; }
const bool WithGrantOption() const { return with_grant_option_; }

private:
std::optional<std::string> target_type_;
std::string database_;
std::string target_;
std::vector<std::string> privileges_;
bool is_all_privileges_;
std::vector<std::string> grantees_;
bool with_grant_option_;
};

class RevokePlanNode : public LeafPlanNode {
public:
explicit RevokePlanNode(std::optional<std::string> target_type, std::string database, std::string target,
std::vector<std::string> privileges, bool is_all_privileges,
std::vector<std::string> grantees)
: LeafPlanNode(kPlanTypeRevoke),
target_type_(target_type),
database_(database),
target_(target),
privileges_(privileges),
is_all_privileges_(is_all_privileges),
grantees_(grantees) {}
~RevokePlanNode() = default;
const std::vector<std::string> Privileges() const { return privileges_; }
const std::vector<std::string> Grantees() const { return grantees_; }
const std::string Database() const { return database_; }
const std::string Target() const { return target_; }
const std::optional<std::string> TargetType() const { return target_type_; }
const bool IsAllPrivileges() const { return is_all_privileges_; }

private:
std::optional<std::string> target_type_;
std::string database_;
std::string target_;
std::vector<std::string> privileges_;
bool is_all_privileges_;
std::vector<std::string> grantees_;
};

class AlterUserPlanNode : public LeafPlanNode {
public:
explicit AlterUserPlanNode(const std::string& name, bool if_exists, std::shared_ptr<OptionsMap> options)
Expand Down
58 changes: 58 additions & 0 deletions hybridse/include/node/sql_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -2430,6 +2430,64 @@ class AlterUserNode : public SqlNode {
const std::shared_ptr<OptionsMap> options_;
};

class GrantNode : public SqlNode {
public:
explicit GrantNode(std::optional<std::string> target_type, std::string database, std::string target,
std::vector<std::string> privileges, bool is_all_privileges, std::vector<std::string> grantees,
bool with_grant_option)
: SqlNode(kGrantStmt, 0, 0),
target_type_(target_type),
database_(database),
target_(target),
privileges_(privileges),
is_all_privileges_(is_all_privileges),
grantees_(grantees),
with_grant_option_(with_grant_option) {}
const std::vector<std::string> Privileges() const { return privileges_; }
const std::vector<std::string> Grantees() const { return grantees_; }
const std::string Database() const { return database_; }
const std::string Target() const { return target_; }
const std::optional<std::string> TargetType() const { return target_type_; }
const bool IsAllPrivileges() const { return is_all_privileges_; }
const bool WithGrantOption() const { return with_grant_option_; }

private:
std::optional<std::string> target_type_;
std::string database_;
std::string target_;
std::vector<std::string> privileges_;
bool is_all_privileges_;
std::vector<std::string> grantees_;
bool with_grant_option_;
};

class RevokeNode : public SqlNode {
public:
explicit RevokeNode(std::optional<std::string> target_type, std::string database, std::string target,
std::vector<std::string> privileges, bool is_all_privileges, std::vector<std::string> grantees)
: SqlNode(kRevokeStmt, 0, 0),
target_type_(target_type),
database_(database),
target_(target),
privileges_(privileges),
is_all_privileges_(is_all_privileges),
grantees_(grantees) {}
const std::vector<std::string> Privileges() const { return privileges_; }
const std::vector<std::string> Grantees() const { return grantees_; }
const std::string Database() const { return database_; }
const std::string Target() const { return target_; }
const std::optional<std::string> TargetType() const { return target_type_; }
const bool IsAllPrivileges() const { return is_all_privileges_; }

private:
std::optional<std::string> target_type_;
std::string database_;
std::string target_;
std::vector<std::string> privileges_;
bool is_all_privileges_;
std::vector<std::string> grantees_;
};

class ExplainNode : public SqlNode {
public:
explicit ExplainNode(const QueryNode *query, node::ExplainType explain_type)
Expand Down
4 changes: 4 additions & 0 deletions hybridse/include/vm/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,10 @@ class Engine {
/// request row info exists in 'values' option, as a format of:
/// 1. [(col1_expr, col2_expr, ... ), (...), ...]
/// 2. (col1_expr, col2_expr, ... )
//
// This function only check on request/batchrequest mode, for batch mode it does nothing.
// As for old-fashioned usage, request row does not need to appear in SQL, so it won't report
// error even request rows is empty, instead checks should performed at the very beginning of Compute.
static absl::Status ExtractRequestRowsInSQL(SqlContext* ctx);

std::shared_ptr<CompileInfo> GetCacheLocked(const std::string& db,
Expand Down
Loading

0 comments on commit af99041

Please sign in to comment.