This is an automated email from the ASF dual-hosted git repository.
chengzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 65f9f76d795 fix:Support for three-level naming of table-valued
function (#36019)
65f9f76d795 is described below
commit 65f9f76d795d4bc3dd207542c44d77391f196838
Author: cxy <[email protected]>
AuthorDate: Wed Jul 16 12:41:23 2025 +0800
fix:Support for three-level naming of table-valued function (#36019)
---
.../src/main/antlr4/imports/sqlserver/BaseRule.g4 | 4 ++--
test/it/parser/src/main/resources/case/dml/select.xml | 15 +++++++++++++++
.../src/main/resources/sql/supported/dml/select.xml | 1 +
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git
a/parser/sql/dialect/sqlserver/src/main/antlr4/imports/sqlserver/BaseRule.g4
b/parser/sql/dialect/sqlserver/src/main/antlr4/imports/sqlserver/BaseRule.g4
index 636b192b11a..e635f6254c5 100644
--- a/parser/sql/dialect/sqlserver/src/main/antlr4/imports/sqlserver/BaseRule.g4
+++ b/parser/sql/dialect/sqlserver/src/main/antlr4/imports/sqlserver/BaseRule.g4
@@ -133,7 +133,7 @@ schemaName
;
functionName
- : (owner DOT_)? name
+ : ((databaseName DOT_)? (owner DOT_))? name
;
procedureName
@@ -467,7 +467,7 @@ regularFunction
;
regularFunctionName
- : (owner DOT_)? identifier | IF | LOCALTIME | LOCALTIMESTAMP | INTERVAL
+ : ((databaseName DOT_)? (owner DOT_))? identifier | IF | LOCALTIME |
LOCALTIMESTAMP | INTERVAL
;
caseExpression
diff --git a/test/it/parser/src/main/resources/case/dml/select.xml
b/test/it/parser/src/main/resources/case/dml/select.xml
index 1274b093755..9c79674f1a5 100644
--- a/test/it/parser/src/main/resources/case/dml/select.xml
+++ b/test/it/parser/src/main/resources/case/dml/select.xml
@@ -10897,4 +10897,19 @@
</expression-projection>
</projections>
</select>
+
+ <select sql-case-id="select_from_msdb_managed_backup">
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7"/>
+ </projections>
+ <from start-index="14" stop-index="63">
+ <function-table start-index="14" stop-index="63">
+ <table-function
function-name="msdb.managed_backup.fn_available_backups"
text="msdb.managed_backup.fn_available_backups ('MyDB')">
+ <parameter>
+ <literal-expression value="MyDB" start-index="57"
stop-index="62"/>
+ </parameter>
+ </table-function>
+ </function-table>
+ </from>
+ </select>
</sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/sql/supported/dml/select.xml
b/test/it/parser/src/main/resources/sql/supported/dml/select.xml
index f0d59fe25e7..f83184025d3 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/select.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/select.xml
@@ -339,4 +339,5 @@
<sql-case id="select_sqlserver_current_user" value="SELECT CURRENT_USER;"
db-types="SQLServer"/>
<sql-case id="select_parse_function" value="SELECT PARSE('Monday, 13
December 2010' AS datetime2 USING 'en-US') AS Result;" db-types="SQLServer"/>
<sql-case id="select_try_parse_function" value="SELECT
TRY_PARSE('Jabberwokkie' AS datetime2 USING 'en-US') AS Result;"
db-types="SQLServer"/>
+ <sql-case id="select_from_msdb_managed_backup" value="SELECT * FROM
msdb.managed_backup.fn_available_backups ('MyDB');" db-types="SQLServer"/>
</sql-cases>