You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/08/08 15:24:55 UTC

[GitHub] [shardingsphere] Icesource opened a new pull request #11705: add SQLServer grammar Create Function

Icesource opened a new pull request #11705:
URL: https://github.com/apache/shardingsphere/pull/11705


   For #6478.
   
   Changes proposed in this pull request:
   - add SQLServer grammar setVariable
   - add SQLServer grammer declareVariable
   - add SQLServer grammar Create Function
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] jingshanglu commented on a change in pull request #11705: add SQLServer grammar Create Function

Posted by GitBox <gi...@apache.org>.
jingshanglu commented on a change in pull request #11705:
URL: https://github.com/apache/shardingsphere/pull/11705#discussion_r688191126



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/BaseRule.g4
##########
@@ -422,3 +427,7 @@ ignoredIdentifiers
 matchNone
     : 'Default does not match anything'
     ;
+
+variableName
+    : AT_ identifier
+    ;

Review comment:
       @Icesource There should be a empty line at the end of the file.

##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/SQLServerKeyword.g4
##########
@@ -1070,3 +1070,59 @@ FILTER_COLUMN
 RETENTION_PERIOD
     : R E T E N T I O N UL_ P E R I O D
     ;
+
+FORWARD_ONLY
+    : F O R W A R D UL_ O N L Y
+    ;
+
+SCROLL
+    : S C R O L L
+    ;
+
+STATIC
+    : S T A T I C
+    ;
+
+KEYSET
+    : K E Y S E T
+    ;
+
+DYNAMIC
+    : D Y N A M I C
+    ;
+
+FAST_FORWARD
+    : F A S T UL_ F O R W A R D
+    ;
+
+READ_ONLY
+    : R E A D UL_ O N L Y
+    ;
+
+SCROLL_LOCKS
+    : S C R O L L UL_ L O C K S
+    ;
+
+OPTIMISTIC
+    : O P T I M I S T I C
+    ;
+
+TYPE_WARNING
+    : T Y P E UL_ W A R N I N G
+    ;
+
+SCHEMABINDING
+    : S C H E M A B I N D I N G
+    ;
+
+CALLER
+    : C A L L E R
+    ;
+
+INPUT
+    : I N P U T
+    ;
+
+CALLED
+    : C A L L E D
+    ;

Review comment:
       @Icesource There should be a empty line at the end of the file.

##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/SQLServerKeyword.g4
##########
@@ -1070,3 +1070,59 @@ FILTER_COLUMN
 RETENTION_PERIOD
     : R E T E N T I O N UL_ P E R I O D
     ;
+
+FORWARD_ONLY
+    : F O R W A R D UL_ O N L Y
+    ;
+
+SCROLL
+    : S C R O L L
+    ;
+
+STATIC
+    : S T A T I C
+    ;
+
+KEYSET
+    : K E Y S E T
+    ;
+
+DYNAMIC
+    : D Y N A M I C
+    ;
+
+FAST_FORWARD
+    : F A S T UL_ F O R W A R D
+    ;
+
+READ_ONLY
+    : R E A D UL_ O N L Y
+    ;
+
+SCROLL_LOCKS
+    : S C R O L L UL_ L O C K S
+    ;
+
+OPTIMISTIC
+    : O P T I M I S T I C
+    ;
+
+TYPE_WARNING
+    : T Y P E UL_ W A R N I N G
+    ;
+
+SCHEMABINDING
+    : S C H E M A B I N D I N G
+    ;
+
+CALLER
+    : C A L L E R
+    ;
+
+INPUT
+    : I N P U T
+    ;
+
+CALLED
+    : C A L L E D
+    ;

Review comment:
       @Icesource If these tokens are not unreserved keyword, maybe these should be contained in `unreservedWord`(BaseRule.g4). Plz check it refer to https://docs.microsoft.com/en-us/sql/t-sql/language-elements/reserved-keywords-transact-sql?view=sql-server-ver15.

##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/Keyword.g4
##########
@@ -639,3 +639,31 @@ FORCED
 HINT
     : H I N T
     ;
+
+DECLARE
+    : D E C L A R E
+    ;
+
+CURSOR
+    : C U R S O R
+    ;
+
+OF
+    : O F
+    ;
+
+RETURNS
+    : R E T U R N S
+    ;
+
+DATEPART
+    : D A T E P A R T
+    ;
+
+RETURN
+    : R E T U R N
+    ;
+
+READONLY
+    : R E A D O N L Y
+    ;

Review comment:
       @Icesource There should be a empty line at the end of the file.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] jingshanglu commented on a change in pull request #11705: add SQLServer grammar Create Function

Posted by GitBox <gi...@apache.org>.
jingshanglu commented on a change in pull request #11705:
URL: https://github.com/apache/shardingsphere/pull/11705#discussion_r689975598



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/DDLStatement.g4
##########
@@ -450,3 +454,113 @@ onHistoryTableClause
 ifExist
     : IF EXISTS
     ;
+
+declareVariable
+    : DECLARE (variable (COMMA_ variable)* | tableVariable)
+    ;
+
+variable
+    : variableName AS? dataType (EQ_ simpleExpr)?
+    | variableName CURSOR
+    ;
+
+tableVariable
+    : variableName AS? variTableTypeDefinition
+    ;
+
+variTableTypeDefinition
+    : TABLE LP_ tableVariableClause (COMMA_ tableVariableClause)* RP_
+    ;
+
+tableVariableClause
+    : variableTableColumnDefinition | variableTableConstraint
+    ;
+
+variableTableColumnDefinition
+    : columnName (dataTypeName | AS expr) (COLLATE collationName)? ((DEFAULT expr)? | IDENTITY (LP_ NUMBER_ COMMA_ NUMBER_ RP_)?) ROWGUIDCOL? variableTableColumnConstraint
+    ;
+
+variableTableColumnConstraint
+    : (NULL | NOT NULL)?
+    | (PRIMARY KEY | UNIQUE)?
+    | CHECK LP_ expr RP_
+    | WITH indexOption
+    ;
+
+variableTableConstraint
+    : (PRIMARY KEY | UNIQUE) LP_ columnName (COMMA_ columnName)* RP_
+    | CHECK expr
+    ;
+
+setVariable
+    : SET variableName setVariableClause
+    ;
+
+setVariableClause
+    : (DOT_ identifier)? EQ_ (expr | identifier DOT_ identifier | NCHAR_TEXT)
+    | compoundOperation expr
+    | EQ_ cursorVariable
+    | EQ_ LP_ select RP_
+    ;
+
+cursorVariable
+    : variableName
+    | CURSOR cursorClause FOR select (FOR (READ_ONLY | UPDATE (OF name (COMMA_ name)*)))
+    ;
+
+cursorClause
+    : (FORWARD_ONLY | SCROLL)? (STATIC | KEYSET | DYNAMIC | FAST_FORWARD)? (READ_ONLY | SCROLL_LOCKS | OPTIMISTIC)? (TYPE_WARNING)?
+    ;
+
+compoundOperation
+    : PLUS_ EQ_
+    | MINUS_ EQ_
+    | ASTERISK_ EQ_
+    | SLASH_ EQ_
+    | MOD_ EQ_
+    | AMPERSAND_ EQ_
+    | CARET_ EQ_
+    | VERTICAL_BAR_ EQ_
+    ;
+
+
+funcParameters
+    : LP_ (variableName AS? (owner DOT_)? dataType (EQ_ ignoredIdentifier)? READONLY?)* RP_
+    ;
+
+funcReturns
+    : funcScalarReturn | funcInlineReturn | funcMutiReturn
+    ;
+
+funcMutiReturn
+    : RETURNS variableName TABLE createTableDefinitions (WITH functionOption (COMMA_ functionOption)*)? AS? BEGIN compoundStatement RETURN END
+    ;
+
+funcInlineReturn
+    : RETURNS TABLE (WITH functionOption (COMMA_ functionOption)*)? AS? RETURN LP_? select RP_?
+    ;
+
+funcScalarReturn
+    : RETURNS dataType (WITH functionOption (COMMA_ functionOption)*)? AS? BEGIN compoundStatement RETURN expr
+    ;
+
+tableTypeDefinition
+    : (columnDefinition columnConstraint | computedColumnDefinition) tableConstraint*
+    ;
+
+compoundStatement
+    : validStatement*
+    ;
+
+functionOption
+    : ENCRYPTION?
+    | SCHEMABINDING?
+    | (RETURNS NULL ON NULL INPUT | CALLED ON NULL INPUT)?
+    | (EXECUTE AS CALLER)?
+    | (INLINE = ( ON | OFF ))?
+    ;
+
+validStatement
+    : (createTable | alterTable | dropTable | truncateTable| insert
+    | update | delete | select | setVariable | declareVariable) SEMI_?
+    ;

Review comment:
       @Icesource Same to above.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] jingshanglu commented on a change in pull request #11705: add SQLServer grammar Create Function

Posted by GitBox <gi...@apache.org>.
jingshanglu commented on a change in pull request #11705:
URL: https://github.com/apache/shardingsphere/pull/11705#discussion_r689193571



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/DDLStatement.g4
##########
@@ -450,3 +454,113 @@ onHistoryTableClause
 ifExist
     : IF EXISTS
     ;
+
+declareVariable
+    : DECLARE (variable (COMMA_ variable)* | tableVariable)
+    ;
+
+variable
+    : variableName AS? dataType (EQ_ simpleExpr)?
+    | variableName CURSOR
+    ;
+
+tableVariable
+    : variableName AS? variTableTypeDefinition
+    ;
+
+variTableTypeDefinition
+    : TABLE LP_ tableVariableClause (COMMA_ tableVariableClause)* RP_
+    ;
+
+tableVariableClause
+    : variableTableColumnDefinition | variableTableConstraint
+    ;
+
+variableTableColumnDefinition
+    : columnName (dataTypeName | AS expr) (COLLATE collationName)? ((DEFAULT expr)? | IDENTITY (LP_ NUMBER_ COMMA_ NUMBER_ RP_)?) ROWGUIDCOL? variableTableColumnConstraint
+    ;
+
+variableTableColumnConstraint
+    : (NULL | NOT NULL)?
+    | (PRIMARY KEY | UNIQUE)?
+    | CHECK LP_ expr RP_
+    | WITH indexOption
+    ;
+
+variableTableConstraint
+    : (PRIMARY KEY | UNIQUE) LP_ columnName (COMMA_ columnName)* RP_
+    | CHECK expr
+    ;
+
+setVariable
+    : SET variableName setVariableClause
+    ;
+
+setVariableClause
+    : (DOT_ identifier)? EQ_ (expr | identifier DOT_ identifier | NCHAR_TEXT)
+    | compoundOperation expr
+    | EQ_ cursorVariable
+    | EQ_ LP_ select RP_
+    ;
+
+cursorVariable
+    : variableName
+    | CURSOR cursorClause FOR select (FOR (READ_ONLY | UPDATE (OF name (COMMA_ name)*)))
+    ;
+
+cursorClause
+    : (FORWARD_ONLY | SCROLL)? (STATIC | KEYSET | DYNAMIC | FAST_FORWARD)? (READ_ONLY | SCROLL_LOCKS | OPTIMISTIC)? (TYPE_WARNING)?
+    ;
+
+compoundOperation
+    : PLUS_ EQ_
+    | MINUS_ EQ_
+    | ASTERISK_ EQ_
+    | SLASH_ EQ_
+    | MOD_ EQ_
+    | AMPERSAND_ EQ_
+    | CARET_ EQ_
+    | VERTICAL_BAR_ EQ_
+    ;
+
+
+funcParameters
+    : LP_ (variableName AS? (owner DOT_)? dataType (EQ_ ignoredIdentifier)? READONLY?)* RP_
+    ;
+
+funcReturns
+    : funcScalarReturn | funcInlineReturn | funcMutiReturn
+    ;
+
+funcMutiReturn
+    : RETURNS variableName TABLE createTableDefinitions (WITH functionOption (COMMA_ functionOption)*)? AS? BEGIN compoundStatement RETURN END SEMI_?
+    ;
+
+funcInlineReturn
+    : RETURNS TABLE (WITH functionOption (COMMA_ functionOption)*)? AS? RETURN LP_? select RP_?
+    ;
+
+funcScalarReturn
+    : RETURNS dataType (WITH functionOption (COMMA_ functionOption)*)? AS? BEGIN compoundStatement RETURN expr SEMI_?

Review comment:
       > @jingshanglu these `SEMI_` should be retained. They are special return statements in CREATE FUNCTION, so they are not defined in `SQLServerStatement.g4`. And the `SEMI_` of this part is according to the official documents.
   
   @Icesource `SEMI_` is defined in `SQLServerStatement.g4`(https://github.com/apache/shardingsphere/blob/master/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/SQLServerStatement.g4), and `SEMI_` may 
    be not special in `CREATE FUNCTION`,`UPDATE` also have it, refer to https://docs.microsoft.com/zh-cn/sql/t-sql/queries/update-transact-sql?view=sql-server-ver15.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] codecov-commenter edited a comment on pull request #11705: add SQLServer grammar Create Function

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #11705:
URL: https://github.com/apache/shardingsphere/pull/11705#issuecomment-894818170


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#11705](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (c4125e5) into [master](https://codecov.io/gh/apache/shardingsphere/commit/3d008c7b2294f8294c341f706f501eab924247f5?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (3d008c7) will **decrease** coverage by `0.00%`.
   > The diff coverage is `50.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/11705/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #11705      +/-   ##
   ============================================
   - Coverage     63.44%   63.44%   -0.01%     
     Complexity     1203     1203              
   ============================================
     Files          2320     2321       +1     
     Lines         35002    35004       +2     
     Branches       6077     6077              
   ============================================
   + Hits          22206    22207       +1     
   - Misses        11003    11004       +1     
     Partials       1793     1793              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...qlserver/ddl/SQLServerCreateFunctionStatement.java](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLXN0YXRlbWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsL3BhcnNlci9zcWwvZGlhbGVjdC9zdGF0ZW1lbnQvc3Fsc2VydmVyL2RkbC9TUUxTZXJ2ZXJDcmVhdGVGdW5jdGlvblN0YXRlbWVudC5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...tatement/impl/SQLServerDDLStatementSQLVisitor.java](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLWRpYWxlY3Qvc2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci1zcWxzZXJ2ZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NxbC9wYXJzZXIvc3Fsc2VydmVyL3Zpc2l0b3Ivc3RhdGVtZW50L2ltcGwvU1FMU2VydmVyRERMU3RhdGVtZW50U1FMVmlzaXRvci5qYXZh) | `82.60% <100.00%> (+0.12%)` | :arrow_up: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [3d008c7...c4125e5](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] Icesource commented on pull request #11705: add SQLServer grammar Create Function

Posted by GitBox <gi...@apache.org>.
Icesource commented on pull request #11705:
URL: https://github.com/apache/shardingsphere/pull/11705#issuecomment-896500184


   > Hi, @jingshanglu , I've added SQL definition for SQLServer Create Function statement. Please check it.
   
   Hi, @jingshanglu , this is my newly submitted pull request. Could you check it for me ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] Icesource commented on pull request #11705: add SQLServer grammar Create Function

Posted by GitBox <gi...@apache.org>.
Icesource commented on pull request #11705:
URL: https://github.com/apache/shardingsphere/pull/11705#issuecomment-895298935


   Hi, @jingshanglu , I've added SQL definition for SQLServer Create Function statement. Please check it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] jingshanglu merged pull request #11705: add SQLServer grammar Create Function

Posted by GitBox <gi...@apache.org>.
jingshanglu merged pull request #11705:
URL: https://github.com/apache/shardingsphere/pull/11705


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] Icesource commented on a change in pull request #11705: add SQLServer grammar Create Function

Posted by GitBox <gi...@apache.org>.
Icesource commented on a change in pull request #11705:
URL: https://github.com/apache/shardingsphere/pull/11705#discussion_r690512928



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/DDLStatement.g4
##########
@@ -450,3 +454,113 @@ onHistoryTableClause
 ifExist
     : IF EXISTS
     ;
+
+declareVariable
+    : DECLARE (variable (COMMA_ variable)* | tableVariable)
+    ;
+
+variable
+    : variableName AS? dataType (EQ_ simpleExpr)?
+    | variableName CURSOR
+    ;
+
+tableVariable
+    : variableName AS? variTableTypeDefinition
+    ;
+
+variTableTypeDefinition
+    : TABLE LP_ tableVariableClause (COMMA_ tableVariableClause)* RP_
+    ;
+
+tableVariableClause
+    : variableTableColumnDefinition | variableTableConstraint
+    ;
+
+variableTableColumnDefinition
+    : columnName (dataTypeName | AS expr) (COLLATE collationName)? ((DEFAULT expr)? | IDENTITY (LP_ NUMBER_ COMMA_ NUMBER_ RP_)?) ROWGUIDCOL? variableTableColumnConstraint
+    ;
+
+variableTableColumnConstraint
+    : (NULL | NOT NULL)?
+    | (PRIMARY KEY | UNIQUE)?
+    | CHECK LP_ expr RP_
+    | WITH indexOption
+    ;
+
+variableTableConstraint
+    : (PRIMARY KEY | UNIQUE) LP_ columnName (COMMA_ columnName)* RP_
+    | CHECK expr
+    ;
+
+setVariable
+    : SET variableName setVariableClause
+    ;
+
+setVariableClause
+    : (DOT_ identifier)? EQ_ (expr | identifier DOT_ identifier | NCHAR_TEXT)
+    | compoundOperation expr
+    | EQ_ cursorVariable
+    | EQ_ LP_ select RP_
+    ;
+
+cursorVariable
+    : variableName
+    | CURSOR cursorClause FOR select (FOR (READ_ONLY | UPDATE (OF name (COMMA_ name)*)))
+    ;
+
+cursorClause
+    : (FORWARD_ONLY | SCROLL)? (STATIC | KEYSET | DYNAMIC | FAST_FORWARD)? (READ_ONLY | SCROLL_LOCKS | OPTIMISTIC)? (TYPE_WARNING)?
+    ;
+
+compoundOperation
+    : PLUS_ EQ_
+    | MINUS_ EQ_
+    | ASTERISK_ EQ_
+    | SLASH_ EQ_
+    | MOD_ EQ_
+    | AMPERSAND_ EQ_
+    | CARET_ EQ_
+    | VERTICAL_BAR_ EQ_
+    ;
+
+
+funcParameters
+    : LP_ (variableName AS? (owner DOT_)? dataType (EQ_ ignoredIdentifier)? READONLY?)* RP_
+    ;
+
+funcReturns
+    : funcScalarReturn | funcInlineReturn | funcMutiReturn
+    ;
+
+funcMutiReturn
+    : RETURNS variableName TABLE createTableDefinitions (WITH functionOption (COMMA_ functionOption)*)? AS? BEGIN compoundStatement RETURN END
+    ;
+
+funcInlineReturn
+    : RETURNS TABLE (WITH functionOption (COMMA_ functionOption)*)? AS? RETURN LP_? select RP_?
+    ;
+
+funcScalarReturn
+    : RETURNS dataType (WITH functionOption (COMMA_ functionOption)*)? AS? BEGIN compoundStatement RETURN expr
+    ;
+
+tableTypeDefinition
+    : (columnDefinition columnConstraint | computedColumnDefinition) tableConstraint*
+    ;
+
+compoundStatement
+    : validStatement*
+    ;
+
+functionOption
+    : ENCRYPTION?
+    | SCHEMABINDING?
+    | (RETURNS NULL ON NULL INPUT | CALLED ON NULL INPUT)?
+    | (EXECUTE AS CALLER)?
+    | (INLINE = ( ON | OFF ))?
+    ;
+
+validStatement
+    : (createTable | alterTable | dropTable | truncateTable| insert
+    | update | delete | select | setVariable | declareVariable) SEMI_?
+    ;

Review comment:
       @jingshanglu I checked here. The ```SEMI_``` should be reserved. Here I refer to the definition in the DDLStatment.g4 file of Mysql. The Create Function statement can embed other SQL statements instead of directly referencing the execute syntax in SQLServerStatement.g4. For example, 
   ```
   CREATE FUNCTION dbo.ISOweek (@DATE datetime)
   RETURNS int
   WITH EXECUTE AS CALLER
   AS
   BEGIN
       DECLARE @ISOweek int;
       SET @ISOweek= DATEPART(wk,@DATE)+1
           -DATEPART(wk,CAST(DATEPART(yy,@DATE) as CHAR(4))+'0104');
       RETURN(@ISOweek);
   END;
   ```
   If this is removed, the embedded SQL statement cannot be matched. 
   Or can I directly use the execute syntax in SQLServerStatement.g4 here?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] Icesource commented on a change in pull request #11705: add SQLServer grammar Create Function

Posted by GitBox <gi...@apache.org>.
Icesource commented on a change in pull request #11705:
URL: https://github.com/apache/shardingsphere/pull/11705#discussion_r689106474



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/DDLStatement.g4
##########
@@ -27,6 +27,10 @@ createIndex
     : CREATE createIndexSpecification INDEX indexName ON tableName columnNamesWithSort
     ;
 
+createFunction
+    : CREATE (OR ALTER)? FUNCTION functionName funcParameters funcReturns SEMI_?
+    ;
+

Review comment:
       @jingshanglu  Of course, this ```SEMI_``` should be removed.  Done.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] codecov-commenter edited a comment on pull request #11705: add SQLServer grammar Create Function

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #11705:
URL: https://github.com/apache/shardingsphere/pull/11705#issuecomment-894818170


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#11705](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (2e8a377) into [master](https://codecov.io/gh/apache/shardingsphere/commit/6afc1a9f9c42ad227fd1391ffe1683c1f477420f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (6afc1a9) will **decrease** coverage by `0.15%`.
   > The diff coverage is `50.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/11705/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #11705      +/-   ##
   ============================================
   - Coverage     63.69%   63.53%   -0.16%     
   - Complexity     1122     1195      +73     
   ============================================
     Files          2267     2308      +41     
     Lines         34617    34814     +197     
     Branches       6029     6043      +14     
   ============================================
   + Hits          22048    22118      +70     
   - Misses        10806    10917     +111     
   - Partials       1763     1779      +16     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...qlserver/ddl/SQLServerCreateFunctionStatement.java](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLXN0YXRlbWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsL3BhcnNlci9zcWwvZGlhbGVjdC9zdGF0ZW1lbnQvc3Fsc2VydmVyL2RkbC9TUUxTZXJ2ZXJDcmVhdGVGdW5jdGlvblN0YXRlbWVudC5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...tatement/impl/SQLServerDDLStatementSQLVisitor.java](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLWRpYWxlY3Qvc2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci1zcWxzZXJ2ZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NxbC9wYXJzZXIvc3Fsc2VydmVyL3Zpc2l0b3Ivc3RhdGVtZW50L2ltcGwvU1FMU2VydmVyRERMU3RhdGVtZW50U1FMVmlzaXRvci5qYXZh) | `82.60% <100.00%> (+0.12%)` | :arrow_up: |
   | [...ig/swapper/YamlDataSourceConfigurationSwapper.java](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS95YW1sL2NvbmZpZy9zd2FwcGVyL1lhbWxEYXRhU291cmNlQ29uZmlndXJhdGlvblN3YXBwZXIuamF2YQ==) | `68.75% <0.00%> (-31.25%)` | :arrow_down: |
   | [.../driver/jdbc/adapter/AbstractStatementAdapter.java](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtamRiYy9zaGFyZGluZ3NwaGVyZS1qZGJjLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RyaXZlci9qZGJjL2FkYXB0ZXIvQWJzdHJhY3RTdGF0ZW1lbnRBZGFwdGVyLmphdmE=) | `79.68% <0.00%> (-15.63%)` | :arrow_down: |
   | [...api/definition/MetricsPluginDefinitionService.java](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtcGx1Z2lucy9zaGFyZGluZ3NwaGVyZS1hZ2VudC1wbHVnaW4tbWV0cmljcy9zaGFyZGluZ3NwaGVyZS1hZ2VudC1tZXRyaWNzLWFwaS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvbWV0cmljcy9hcGkvZGVmaW5pdGlvbi9NZXRyaWNzUGx1Z2luRGVmaW5pdGlvblNlcnZpY2UuamF2YQ==) | `66.66% <0.00%> (-15.39%)` | :arrow_down: |
   | [.../registry/ShardingSphereAlgorithmBeanRegistry.java](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtamRiYy9zaGFyZGluZ3NwaGVyZS1qZGJjLXNwcmluZy9zaGFyZGluZ3NwaGVyZS1qZGJjLXNwcmluZy1pbmZyYS9zaGFyZGluZ3NwaGVyZS1qZGJjLXNwcmluZy1uYW1lc3BhY2UtaW5mcmEvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NwcmluZy9uYW1lc3BhY2UvcmVnaXN0cnkvU2hhcmRpbmdTcGhlcmVBbGdvcml0aG1CZWFuUmVnaXN0cnkuamF2YQ==) | `87.50% <0.00%> (-12.50%)` | :arrow_down: |
   | [...sphere/sharding/route/engine/condition/Column.java](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvcm91dGUvZW5naW5lL2NvbmRpdGlvbi9Db2x1bW4uamF2YQ==) | `90.00% <0.00%> (-10.00%)` | :arrow_down: |
   | [...e/shardingsphere/shadow/route/ShadowSQLRouter.java](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhZG93L3NoYXJkaW5nc3BoZXJlLXNoYWRvdy1jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9zaGFkb3cvcm91dGUvU2hhZG93U1FMUm91dGVyLmphdmE=) | `88.88% <0.00%> (-8.62%)` | :arrow_down: |
   | [...shardingsphere/sharding/rule/BindingTableRule.java](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvcnVsZS9CaW5kaW5nVGFibGVSdWxlLmphdmE=) | `66.66% <0.00%> (-6.42%)` | :arrow_down: |
   | [...ontext/metadata/impl/StandardMetaDataContexts.java](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtY29udGV4dC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvaW5mcmEvY29udGV4dC9tZXRhZGF0YS9pbXBsL1N0YW5kYXJkTWV0YURhdGFDb250ZXh0cy5qYXZh) | `76.47% <0.00%> (-5.89%)` | :arrow_down: |
   | ... and [174 more](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [6afc1a9...2e8a377](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] codecov-commenter edited a comment on pull request #11705: add SQLServer grammar Create Function

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #11705:
URL: https://github.com/apache/shardingsphere/pull/11705#issuecomment-894818170


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#11705](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (9b14ff8) into [master](https://codecov.io/gh/apache/shardingsphere/commit/3d008c7b2294f8294c341f706f501eab924247f5?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (3d008c7) will **decrease** coverage by `0.06%`.
   > The diff coverage is `50.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/11705/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #11705      +/-   ##
   ============================================
   - Coverage     63.44%   63.37%   -0.07%     
   + Complexity     1203     1200       -3     
   ============================================
     Files          2320     2309      -11     
     Lines         35002    34919      -83     
     Branches       6077     6071       -6     
   ============================================
   - Hits          22206    22129      -77     
     Misses        11003    11003              
   + Partials       1793     1787       -6     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...qlserver/ddl/SQLServerCreateFunctionStatement.java](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLXN0YXRlbWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsL3BhcnNlci9zcWwvZGlhbGVjdC9zdGF0ZW1lbnQvc3Fsc2VydmVyL2RkbC9TUUxTZXJ2ZXJDcmVhdGVGdW5jdGlvblN0YXRlbWVudC5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...tatement/impl/SQLServerDDLStatementSQLVisitor.java](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLWRpYWxlY3Qvc2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci1zcWxzZXJ2ZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NxbC9wYXJzZXIvc3Fsc2VydmVyL3Zpc2l0b3Ivc3RhdGVtZW50L2ltcGwvU1FMU2VydmVyRERMU3RhdGVtZW50U1FMVmlzaXRvci5qYXZh) | `82.60% <100.00%> (+0.12%)` | :arrow_up: |
   | [...tor/dml/impl/ShardingSelectStatementValidator.java](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvcm91dGUvZW5naW5lL3ZhbGlkYXRvci9kbWwvaW1wbC9TaGFyZGluZ1NlbGVjdFN0YXRlbWVudFZhbGlkYXRvci5qYXZh) | `33.33% <0.00%> (-44.45%)` | :arrow_down: |
   | [...e/validator/dml/ShardingDMLStatementValidator.java](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmcvc2hhcmRpbmdzcGhlcmUtc2hhcmRpbmctY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvcm91dGUvZW5naW5lL3ZhbGlkYXRvci9kbWwvU2hhcmRpbmdETUxTdGF0ZW1lbnRWYWxpZGF0b3IuamF2YQ==) | `25.58% <0.00%> (-42.28%)` | :arrow_down: |
   | [...re/config/yaml/ServerConfigurationYamlSwapper.java](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc2NhbGluZy9zaGFyZGluZ3NwaGVyZS1zY2FsaW5nLWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NjYWxpbmcvY29yZS9jb25maWcveWFtbC9TZXJ2ZXJDb25maWd1cmF0aW9uWWFtbFN3YXBwZXIuamF2YQ==) | `86.66% <0.00%> (-0.84%)` | :arrow_down: |
   | [...a/binder/statement/dml/SelectStatementContext.java](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtYmluZGVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9iaW5kZXIvc3RhdGVtZW50L2RtbC9TZWxlY3RTdGF0ZW1lbnRDb250ZXh0LmphdmE=) | `73.56% <0.00%> (-0.60%)` | :arrow_down: |
   | [...a/binder/statement/dml/InsertStatementContext.java](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtYmluZGVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9iaW5kZXIvc3RhdGVtZW50L2RtbC9JbnNlcnRTdGF0ZW1lbnRDb250ZXh0LmphdmE=) | `97.64% <0.00%> (-0.11%)` | :arrow_down: |
   | [...here/infra/binder/segment/table/TablesContext.java](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtYmluZGVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9iaW5kZXIvc2VnbWVudC90YWJsZS9UYWJsZXNDb250ZXh0LmphdmE=) | `71.79% <0.00%> (ø)` | |
   | [...a/binder/statement/dml/DeleteStatementContext.java](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtYmluZGVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9iaW5kZXIvc3RhdGVtZW50L2RtbC9EZWxldGVTdGF0ZW1lbnRDb250ZXh0LmphdmE=) | `100.00% <0.00%> (ø)` | |
   | [...a/binder/statement/dml/UpdateStatementContext.java](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtYmluZGVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9iaW5kZXIvc3RhdGVtZW50L2RtbC9VcGRhdGVTdGF0ZW1lbnRDb250ZXh0LmphdmE=) | `100.00% <0.00%> (ø)` | |
   | ... and [20 more](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [3d008c7...9b14ff8](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] Icesource commented on a change in pull request #11705: add SQLServer grammar Create Function

Posted by GitBox <gi...@apache.org>.
Icesource commented on a change in pull request #11705:
URL: https://github.com/apache/shardingsphere/pull/11705#discussion_r688648251



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/BaseRule.g4
##########
@@ -422,3 +427,7 @@ ignoredIdentifiers
 matchNone
     : 'Default does not match anything'
     ;
+
+variableName
+    : AT_ identifier
+    ;

Review comment:
       @jingshanglu done

##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/Keyword.g4
##########
@@ -639,3 +639,31 @@ FORCED
 HINT
     : H I N T
     ;
+
+DECLARE
+    : D E C L A R E
+    ;
+
+CURSOR
+    : C U R S O R
+    ;
+
+OF
+    : O F
+    ;
+
+RETURNS
+    : R E T U R N S
+    ;
+
+DATEPART
+    : D A T E P A R T
+    ;
+
+RETURN
+    : R E T U R N
+    ;
+
+READONLY
+    : R E A D O N L Y
+    ;

Review comment:
       @jingshanglu done

##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/SQLServerKeyword.g4
##########
@@ -1070,3 +1070,59 @@ FILTER_COLUMN
 RETENTION_PERIOD
     : R E T E N T I O N UL_ P E R I O D
     ;
+
+FORWARD_ONLY
+    : F O R W A R D UL_ O N L Y
+    ;
+
+SCROLL
+    : S C R O L L
+    ;
+
+STATIC
+    : S T A T I C
+    ;
+
+KEYSET
+    : K E Y S E T
+    ;
+
+DYNAMIC
+    : D Y N A M I C
+    ;
+
+FAST_FORWARD
+    : F A S T UL_ F O R W A R D
+    ;
+
+READ_ONLY
+    : R E A D UL_ O N L Y
+    ;
+
+SCROLL_LOCKS
+    : S C R O L L UL_ L O C K S
+    ;
+
+OPTIMISTIC
+    : O P T I M I S T I C
+    ;
+
+TYPE_WARNING
+    : T Y P E UL_ W A R N I N G
+    ;
+
+SCHEMABINDING
+    : S C H E M A B I N D I N G
+    ;
+
+CALLER
+    : C A L L E R
+    ;
+
+INPUT
+    : I N P U T
+    ;
+
+CALLED
+    : C A L L E D
+    ;

Review comment:
       @jingshanglu  done




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] Icesource commented on a change in pull request #11705: add SQLServer grammar Create Function

Posted by GitBox <gi...@apache.org>.
Icesource commented on a change in pull request #11705:
URL: https://github.com/apache/shardingsphere/pull/11705#discussion_r689106875



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/DDLStatement.g4
##########
@@ -450,3 +454,113 @@ onHistoryTableClause
 ifExist
     : IF EXISTS
     ;
+
+declareVariable
+    : DECLARE (variable (COMMA_ variable)* | tableVariable)
+    ;
+
+variable
+    : variableName AS? dataType (EQ_ simpleExpr)?
+    | variableName CURSOR
+    ;
+
+tableVariable
+    : variableName AS? variTableTypeDefinition
+    ;
+
+variTableTypeDefinition
+    : TABLE LP_ tableVariableClause (COMMA_ tableVariableClause)* RP_
+    ;
+
+tableVariableClause
+    : variableTableColumnDefinition | variableTableConstraint
+    ;
+
+variableTableColumnDefinition
+    : columnName (dataTypeName | AS expr) (COLLATE collationName)? ((DEFAULT expr)? | IDENTITY (LP_ NUMBER_ COMMA_ NUMBER_ RP_)?) ROWGUIDCOL? variableTableColumnConstraint
+    ;
+
+variableTableColumnConstraint
+    : (NULL | NOT NULL)?
+    | (PRIMARY KEY | UNIQUE)?
+    | CHECK LP_ expr RP_
+    | WITH indexOption
+    ;
+
+variableTableConstraint
+    : (PRIMARY KEY | UNIQUE) LP_ columnName (COMMA_ columnName)* RP_
+    | CHECK expr
+    ;
+
+setVariable
+    : SET variableName setVariableClause
+    ;
+
+setVariableClause
+    : (DOT_ identifier)? EQ_ (expr | identifier DOT_ identifier | NCHAR_TEXT)
+    | compoundOperation expr
+    | EQ_ cursorVariable
+    | EQ_ LP_ select RP_
+    ;
+
+cursorVariable
+    : variableName
+    | CURSOR cursorClause FOR select (FOR (READ_ONLY | UPDATE (OF name (COMMA_ name)*)))
+    ;
+
+cursorClause
+    : (FORWARD_ONLY | SCROLL)? (STATIC | KEYSET | DYNAMIC | FAST_FORWARD)? (READ_ONLY | SCROLL_LOCKS | OPTIMISTIC)? (TYPE_WARNING)?
+    ;
+
+compoundOperation
+    : PLUS_ EQ_
+    | MINUS_ EQ_
+    | ASTERISK_ EQ_
+    | SLASH_ EQ_
+    | MOD_ EQ_
+    | AMPERSAND_ EQ_
+    | CARET_ EQ_
+    | VERTICAL_BAR_ EQ_
+    ;
+
+
+funcParameters
+    : LP_ (variableName AS? (owner DOT_)? dataType (EQ_ ignoredIdentifier)? READONLY?)* RP_
+    ;
+
+funcReturns
+    : funcScalarReturn | funcInlineReturn | funcMutiReturn
+    ;
+
+funcMutiReturn
+    : RETURNS variableName TABLE createTableDefinitions (WITH functionOption (COMMA_ functionOption)*)? AS? BEGIN compoundStatement RETURN END SEMI_?
+    ;
+
+funcInlineReturn
+    : RETURNS TABLE (WITH functionOption (COMMA_ functionOption)*)? AS? RETURN LP_? select RP_?
+    ;
+
+funcScalarReturn
+    : RETURNS dataType (WITH functionOption (COMMA_ functionOption)*)? AS? BEGIN compoundStatement RETURN expr SEMI_?

Review comment:
       @jingshanglu  these ```SEMI_``` should be retained. They are special return statements in CREATE FUNCTION, so they are not defined in ```SQLServerStatement.g4```. And the ```SEMI_``` of this part is according to the official documents. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] codecov-commenter commented on pull request #11705: add SQLServer grammar Create Function

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #11705:
URL: https://github.com/apache/shardingsphere/pull/11705#issuecomment-894818170


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#11705](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (7715ddc) into [master](https://codecov.io/gh/apache/shardingsphere/commit/6afc1a9f9c42ad227fd1391ffe1683c1f477420f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (6afc1a9) will **decrease** coverage by `0.00%`.
   > The diff coverage is `50.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/11705/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #11705      +/-   ##
   ============================================
   - Coverage     63.69%   63.69%   -0.01%     
     Complexity     1122     1122              
   ============================================
     Files          2267     2268       +1     
     Lines         34617    34619       +2     
     Branches       6029     6029              
   ============================================
   + Hits          22048    22049       +1     
   - Misses        10806    10807       +1     
     Partials       1763     1763              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...qlserver/ddl/SQLServerCreateFunctionStatement.java](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLXN0YXRlbWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsL3BhcnNlci9zcWwvZGlhbGVjdC9zdGF0ZW1lbnQvc3Fsc2VydmVyL2RkbC9TUUxTZXJ2ZXJDcmVhdGVGdW5jdGlvblN0YXRlbWVudC5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...tatement/impl/SQLServerDDLStatementSQLVisitor.java](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLWRpYWxlY3Qvc2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci1zcWxzZXJ2ZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NxbC9wYXJzZXIvc3Fsc2VydmVyL3Zpc2l0b3Ivc3RhdGVtZW50L2ltcGwvU1FMU2VydmVyRERMU3RhdGVtZW50U1FMVmlzaXRvci5qYXZh) | `82.60% <100.00%> (+0.12%)` | :arrow_up: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [6afc1a9...7715ddc](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] codecov-commenter edited a comment on pull request #11705: add SQLServer grammar Create Function

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #11705:
URL: https://github.com/apache/shardingsphere/pull/11705#issuecomment-894818170


   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#11705](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (61cfaed) into [master](https://codecov.io/gh/apache/shardingsphere/commit/3d008c7b2294f8294c341f706f501eab924247f5?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (3d008c7) will **decrease** coverage by `0.00%`.
   > The diff coverage is `50.00%`.
   
   > :exclamation: Current head 61cfaed differs from pull request most recent head c4125e5. Consider uploading reports for the commit c4125e5 to get more accurate results
   [![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/11705/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #11705      +/-   ##
   ============================================
   - Coverage     63.44%   63.44%   -0.01%     
     Complexity     1203     1203              
   ============================================
     Files          2320     2321       +1     
     Lines         35002    35004       +2     
     Branches       6077     6077              
   ============================================
   + Hits          22206    22207       +1     
   - Misses        11003    11004       +1     
     Partials       1793     1793              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...qlserver/ddl/SQLServerCreateFunctionStatement.java](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLXN0YXRlbWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsL3BhcnNlci9zcWwvZGlhbGVjdC9zdGF0ZW1lbnQvc3Fsc2VydmVyL2RkbC9TUUxTZXJ2ZXJDcmVhdGVGdW5jdGlvblN0YXRlbWVudC5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...tatement/impl/SQLServerDDLStatementSQLVisitor.java](https://codecov.io/gh/apache/shardingsphere/pull/11705/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLWRpYWxlY3Qvc2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci1zcWxzZXJ2ZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NxbC9wYXJzZXIvc3Fsc2VydmVyL3Zpc2l0b3Ivc3RhdGVtZW50L2ltcGwvU1FMU2VydmVyRERMU3RhdGVtZW50U1FMVmlzaXRvci5qYXZh) | `82.60% <100.00%> (+0.12%)` | :arrow_up: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [3d008c7...c4125e5](https://codecov.io/gh/apache/shardingsphere/pull/11705?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] jingshanglu merged pull request #11705: add SQLServer grammar Create Function

Posted by GitBox <gi...@apache.org>.
jingshanglu merged pull request #11705:
URL: https://github.com/apache/shardingsphere/pull/11705


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] Icesource commented on a change in pull request #11705: add SQLServer grammar Create Function

Posted by GitBox <gi...@apache.org>.
Icesource commented on a change in pull request #11705:
URL: https://github.com/apache/shardingsphere/pull/11705#discussion_r689672718



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/DDLStatement.g4
##########
@@ -450,3 +454,113 @@ onHistoryTableClause
 ifExist
     : IF EXISTS
     ;
+
+declareVariable
+    : DECLARE (variable (COMMA_ variable)* | tableVariable)
+    ;
+
+variable
+    : variableName AS? dataType (EQ_ simpleExpr)?
+    | variableName CURSOR
+    ;
+
+tableVariable
+    : variableName AS? variTableTypeDefinition
+    ;
+
+variTableTypeDefinition
+    : TABLE LP_ tableVariableClause (COMMA_ tableVariableClause)* RP_
+    ;
+
+tableVariableClause
+    : variableTableColumnDefinition | variableTableConstraint
+    ;
+
+variableTableColumnDefinition
+    : columnName (dataTypeName | AS expr) (COLLATE collationName)? ((DEFAULT expr)? | IDENTITY (LP_ NUMBER_ COMMA_ NUMBER_ RP_)?) ROWGUIDCOL? variableTableColumnConstraint
+    ;
+
+variableTableColumnConstraint
+    : (NULL | NOT NULL)?
+    | (PRIMARY KEY | UNIQUE)?
+    | CHECK LP_ expr RP_
+    | WITH indexOption
+    ;
+
+variableTableConstraint
+    : (PRIMARY KEY | UNIQUE) LP_ columnName (COMMA_ columnName)* RP_
+    | CHECK expr
+    ;
+
+setVariable
+    : SET variableName setVariableClause
+    ;
+
+setVariableClause
+    : (DOT_ identifier)? EQ_ (expr | identifier DOT_ identifier | NCHAR_TEXT)
+    | compoundOperation expr
+    | EQ_ cursorVariable
+    | EQ_ LP_ select RP_
+    ;
+
+cursorVariable
+    : variableName
+    | CURSOR cursorClause FOR select (FOR (READ_ONLY | UPDATE (OF name (COMMA_ name)*)))
+    ;
+
+cursorClause
+    : (FORWARD_ONLY | SCROLL)? (STATIC | KEYSET | DYNAMIC | FAST_FORWARD)? (READ_ONLY | SCROLL_LOCKS | OPTIMISTIC)? (TYPE_WARNING)?
+    ;
+
+compoundOperation
+    : PLUS_ EQ_
+    | MINUS_ EQ_
+    | ASTERISK_ EQ_
+    | SLASH_ EQ_
+    | MOD_ EQ_
+    | AMPERSAND_ EQ_
+    | CARET_ EQ_
+    | VERTICAL_BAR_ EQ_
+    ;
+
+
+funcParameters
+    : LP_ (variableName AS? (owner DOT_)? dataType (EQ_ ignoredIdentifier)? READONLY?)* RP_
+    ;
+
+funcReturns
+    : funcScalarReturn | funcInlineReturn | funcMutiReturn
+    ;
+
+funcMutiReturn
+    : RETURNS variableName TABLE createTableDefinitions (WITH functionOption (COMMA_ functionOption)*)? AS? BEGIN compoundStatement RETURN END SEMI_?
+    ;
+
+funcInlineReturn
+    : RETURNS TABLE (WITH functionOption (COMMA_ functionOption)*)? AS? RETURN LP_? select RP_?
+    ;
+
+funcScalarReturn
+    : RETURNS dataType (WITH functionOption (COMMA_ functionOption)*)? AS? BEGIN compoundStatement RETURN expr SEMI_?

Review comment:
       @jingshanglu  Sure, you are right. It's my fault. I have removed the ```SEMI_``` s. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] Icesource commented on a change in pull request #11705: add SQLServer grammar Create Function

Posted by GitBox <gi...@apache.org>.
Icesource commented on a change in pull request #11705:
URL: https://github.com/apache/shardingsphere/pull/11705#discussion_r690512928



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/DDLStatement.g4
##########
@@ -450,3 +454,113 @@ onHistoryTableClause
 ifExist
     : IF EXISTS
     ;
+
+declareVariable
+    : DECLARE (variable (COMMA_ variable)* | tableVariable)
+    ;
+
+variable
+    : variableName AS? dataType (EQ_ simpleExpr)?
+    | variableName CURSOR
+    ;
+
+tableVariable
+    : variableName AS? variTableTypeDefinition
+    ;
+
+variTableTypeDefinition
+    : TABLE LP_ tableVariableClause (COMMA_ tableVariableClause)* RP_
+    ;
+
+tableVariableClause
+    : variableTableColumnDefinition | variableTableConstraint
+    ;
+
+variableTableColumnDefinition
+    : columnName (dataTypeName | AS expr) (COLLATE collationName)? ((DEFAULT expr)? | IDENTITY (LP_ NUMBER_ COMMA_ NUMBER_ RP_)?) ROWGUIDCOL? variableTableColumnConstraint
+    ;
+
+variableTableColumnConstraint
+    : (NULL | NOT NULL)?
+    | (PRIMARY KEY | UNIQUE)?
+    | CHECK LP_ expr RP_
+    | WITH indexOption
+    ;
+
+variableTableConstraint
+    : (PRIMARY KEY | UNIQUE) LP_ columnName (COMMA_ columnName)* RP_
+    | CHECK expr
+    ;
+
+setVariable
+    : SET variableName setVariableClause
+    ;
+
+setVariableClause
+    : (DOT_ identifier)? EQ_ (expr | identifier DOT_ identifier | NCHAR_TEXT)
+    | compoundOperation expr
+    | EQ_ cursorVariable
+    | EQ_ LP_ select RP_
+    ;
+
+cursorVariable
+    : variableName
+    | CURSOR cursorClause FOR select (FOR (READ_ONLY | UPDATE (OF name (COMMA_ name)*)))
+    ;
+
+cursorClause
+    : (FORWARD_ONLY | SCROLL)? (STATIC | KEYSET | DYNAMIC | FAST_FORWARD)? (READ_ONLY | SCROLL_LOCKS | OPTIMISTIC)? (TYPE_WARNING)?
+    ;
+
+compoundOperation
+    : PLUS_ EQ_
+    | MINUS_ EQ_
+    | ASTERISK_ EQ_
+    | SLASH_ EQ_
+    | MOD_ EQ_
+    | AMPERSAND_ EQ_
+    | CARET_ EQ_
+    | VERTICAL_BAR_ EQ_
+    ;
+
+
+funcParameters
+    : LP_ (variableName AS? (owner DOT_)? dataType (EQ_ ignoredIdentifier)? READONLY?)* RP_
+    ;
+
+funcReturns
+    : funcScalarReturn | funcInlineReturn | funcMutiReturn
+    ;
+
+funcMutiReturn
+    : RETURNS variableName TABLE createTableDefinitions (WITH functionOption (COMMA_ functionOption)*)? AS? BEGIN compoundStatement RETURN END
+    ;
+
+funcInlineReturn
+    : RETURNS TABLE (WITH functionOption (COMMA_ functionOption)*)? AS? RETURN LP_? select RP_?
+    ;
+
+funcScalarReturn
+    : RETURNS dataType (WITH functionOption (COMMA_ functionOption)*)? AS? BEGIN compoundStatement RETURN expr
+    ;
+
+tableTypeDefinition
+    : (columnDefinition columnConstraint | computedColumnDefinition) tableConstraint*
+    ;
+
+compoundStatement
+    : validStatement*
+    ;
+
+functionOption
+    : ENCRYPTION?
+    | SCHEMABINDING?
+    | (RETURNS NULL ON NULL INPUT | CALLED ON NULL INPUT)?
+    | (EXECUTE AS CALLER)?
+    | (INLINE = ( ON | OFF ))?
+    ;
+
+validStatement
+    : (createTable | alterTable | dropTable | truncateTable| insert
+    | update | delete | select | setVariable | declareVariable) SEMI_?
+    ;

Review comment:
       @jingshanglu I checked here. The ```SEMI_``` should be reserved. Here I refer to the definition in the DDLStatment.g4 file of Mysql. The Create Function statement can embed other SQL statements instead of directly referencing the execute syntax in SQLServerStatement.g4. For example, 
   ```
   CREATE FUNCTION dbo.ISOweek (@DATE datetime)
   RETURNS int
   WITH EXECUTE AS CALLER
   AS
   BEGIN
       DECLARE @ISOweek int;
       SET @ISOweek= DATEPART(wk,@DATE)+1
           -DATEPART(wk,CAST(DATEPART(yy,@DATE) as CHAR(4))+'0104');
       RETURN(@ISOweek);
   END;
   ```
   If this is removed, the embedded SQL statement cannot be matched. 
   Or can I directly use the execute syntax in SQLServerStatement.g4 here?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] jingshanglu commented on a change in pull request #11705: add SQLServer grammar Create Function

Posted by GitBox <gi...@apache.org>.
jingshanglu commented on a change in pull request #11705:
URL: https://github.com/apache/shardingsphere/pull/11705#discussion_r689021957



##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/DDLStatement.g4
##########
@@ -450,3 +454,113 @@ onHistoryTableClause
 ifExist
     : IF EXISTS
     ;
+
+declareVariable
+    : DECLARE (variable (COMMA_ variable)* | tableVariable)
+    ;
+
+variable
+    : variableName AS? dataType (EQ_ simpleExpr)?
+    | variableName CURSOR
+    ;
+
+tableVariable
+    : variableName AS? variTableTypeDefinition
+    ;
+
+variTableTypeDefinition
+    : TABLE LP_ tableVariableClause (COMMA_ tableVariableClause)* RP_
+    ;
+
+tableVariableClause
+    : variableTableColumnDefinition | variableTableConstraint
+    ;
+
+variableTableColumnDefinition
+    : columnName (dataTypeName | AS expr) (COLLATE collationName)? ((DEFAULT expr)? | IDENTITY (LP_ NUMBER_ COMMA_ NUMBER_ RP_)?) ROWGUIDCOL? variableTableColumnConstraint
+    ;
+
+variableTableColumnConstraint
+    : (NULL | NOT NULL)?
+    | (PRIMARY KEY | UNIQUE)?
+    | CHECK LP_ expr RP_
+    | WITH indexOption
+    ;
+
+variableTableConstraint
+    : (PRIMARY KEY | UNIQUE) LP_ columnName (COMMA_ columnName)* RP_
+    | CHECK expr
+    ;
+
+setVariable
+    : SET variableName setVariableClause
+    ;
+
+setVariableClause
+    : (DOT_ identifier)? EQ_ (expr | identifier DOT_ identifier | NCHAR_TEXT)
+    | compoundOperation expr
+    | EQ_ cursorVariable
+    | EQ_ LP_ select RP_
+    ;
+
+cursorVariable
+    : variableName
+    | CURSOR cursorClause FOR select (FOR (READ_ONLY | UPDATE (OF name (COMMA_ name)*)))
+    ;
+
+cursorClause
+    : (FORWARD_ONLY | SCROLL)? (STATIC | KEYSET | DYNAMIC | FAST_FORWARD)? (READ_ONLY | SCROLL_LOCKS | OPTIMISTIC)? (TYPE_WARNING)?
+    ;
+
+compoundOperation
+    : PLUS_ EQ_
+    | MINUS_ EQ_
+    | ASTERISK_ EQ_
+    | SLASH_ EQ_
+    | MOD_ EQ_
+    | AMPERSAND_ EQ_
+    | CARET_ EQ_
+    | VERTICAL_BAR_ EQ_
+    ;
+
+
+funcParameters
+    : LP_ (variableName AS? (owner DOT_)? dataType (EQ_ ignoredIdentifier)? READONLY?)* RP_
+    ;
+
+funcReturns
+    : funcScalarReturn | funcInlineReturn | funcMutiReturn
+    ;
+
+funcMutiReturn
+    : RETURNS variableName TABLE createTableDefinitions (WITH functionOption (COMMA_ functionOption)*)? AS? BEGIN compoundStatement RETURN END SEMI_?
+    ;
+
+funcInlineReturn
+    : RETURNS TABLE (WITH functionOption (COMMA_ functionOption)*)? AS? RETURN LP_? select RP_?
+    ;
+
+funcScalarReturn
+    : RETURNS dataType (WITH functionOption (COMMA_ functionOption)*)? AS? BEGIN compoundStatement RETURN expr SEMI_?

Review comment:
       @Icesource Are these `SEMI_?` redundant? plz check other `SEMI_?`.

##########
File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-sqlserver/src/main/antlr4/imports/sqlserver/DDLStatement.g4
##########
@@ -27,6 +27,10 @@ createIndex
     : CREATE createIndexSpecification INDEX indexName ON tableName columnNamesWithSort
     ;
 
+createFunction
+    : CREATE (OR ALTER)? FUNCTION functionName funcParameters funcReturns SEMI_?
+    ;
+

Review comment:
       @Icesource Maybe `SEMI_?` is redundant ,`SQLServerStatement.g4` already have it. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org