@@ -645,8 +645,8 @@ base::Status ConvertStatement(const zetasql::ASTStatement* statement, node::Node
645
645
// / support system variable setting and showing in OpenMLDB since v0.4.0
646
646
// / non-support local variable setting in v0.4.0
647
647
const auto ast_system_variable_assign = statement->GetAsOrNull <zetasql::ASTSystemVariableAssignment>();
648
- CHECK_TRUE (nullptr != ast_system_variable_assign, common::kSqlAstError , " not an "
649
- " ASTSystemVariableAssignment" );
648
+ CHECK_TRUE (nullptr != ast_system_variable_assign, common::kSqlAstError ,
649
+ " not an ASTSystemVariableAssignment" );
650
650
std::vector<std::string> path;
651
651
CHECK_STATUS (AstPathExpressionToStringList (ast_system_variable_assign->system_variable ()->path (), path));
652
652
CHECK_TRUE (!path.empty (), common::kSqlAstError , " Non-support empty variable" );
@@ -669,8 +669,7 @@ base::Status ConvertStatement(const zetasql::ASTStatement* statement, node::Node
669
669
dynamic_cast <node::ConstNode*>(value));
670
670
} else {
671
671
FAIL_STATUS (common::kSqlAstError , " Non-support system variable under " , path[0 ],
672
- " scope, try "
673
- " @@global or @@session scope" );
672
+ " scope, try @@global or @@session scope" );
674
673
}
675
674
} else {
676
675
FAIL_STATUS (common::kSqlAstError ,
@@ -679,6 +678,23 @@ base::Status ConvertStatement(const zetasql::ASTStatement* statement, node::Node
679
678
}
680
679
break ;
681
680
}
681
+ case zetasql::AST_SCOPED_VARIABLE_ASSIGNMENT: {
682
+ auto stmt = statement->GetAsOrNull <zetasql::ASTScopedVariableAssignment>();
683
+ CHECK_TRUE (stmt != nullptr , common::kSqlAstError , " not an ASTScopedVariableAssignment" );
684
+ node::ExprNode* value = nullptr ;
685
+ CHECK_STATUS (ConvertExprNode (stmt->expression (), node_manager, &value));
686
+ const node::ConstNode* const_value = dynamic_cast <node::ConstNode*>(value);
687
+ CHECK_TRUE (const_value != nullptr && const_value->GetExprType () == node::kExprPrimary , common::kSqlAstError ,
688
+ " Unsupported Set value other than const type" );
689
+
690
+ const std::string& identifier = stmt->variable ()->GetAsString ();
691
+ auto scope = node::VariableScope::kSessionSystemVariable ;
692
+ if (stmt->scope () == zetasql::ASTScopedVariableAssignment::Scope::GLOBAL) {
693
+ scope = node::VariableScope::kGlobalSystemVariable ;
694
+ }
695
+ *output = node_manager->MakeSetNode (scope, identifier, const_value);
696
+ break ;
697
+ }
682
698
case zetasql::AST_LOAD_DATA_STATEMENT: {
683
699
const auto load_data_stmt = statement->GetAsOrNull <zetasql::ASTLoadDataStatement>();
684
700
CHECK_TRUE (load_data_stmt != nullptr , common::kSqlAstError , " not an ASTLoadDataStatement" );
0 commit comments