korlov42 commented on code in PR #5451:
URL: https://github.com/apache/ignite-3/pull/5451#discussion_r2013777700
##########
modules/sql-engine/src/main/codegen/includes/parserImpls.ftl:
##########
@@ -527,16 +527,176 @@ SqlCreate SqlCreateZone(Span s, boolean replace) :
final boolean ifNotExists;
final SqlIdentifier id;
SqlNodeList optionList = null;
+ SqlNodeList storageProfiles = null;
}
{
<ZONE> { s.add(this); }
ifNotExists = IfNotExistsOpt()
id = CompoundIdentifier()
- [
- <WITH> { s.add(this); } optionList = CreateZoneOptionList()
- ]
+ (
+ <WITH> { s.add(this); } optionList = CreateZoneOptionList()
+ {
+ return new IgniteSqlCreateZone(s.end(this), ifNotExists, id,
optionList);
+ }
+ |
+ (
+ [ optionList = ZoneOptionsList() ]
+
+ <STORAGE> <PROFILES> {
+ storageProfiles = StorageProfiles();
+ }
+ )
+ {
+ SqlIdentifier key = new
SqlIdentifier(ZoneOptionEnum.STORAGE_PROFILES.name(), getPos());
+ IgniteSqlZoneOption profilesOption = new
IgniteSqlZoneOption(key, storageProfiles, getPos());
+ if (optionList != null) {
+ optionList.add(profilesOption);
Review Comment:
storage profile is mandatory attribute. Let's have dedicated field in
`IgniteSqlCreateZone`
##########
modules/sql-engine/src/main/codegen/includes/parserImpls.ftl:
##########
@@ -527,16 +527,176 @@ SqlCreate SqlCreateZone(Span s, boolean replace) :
final boolean ifNotExists;
final SqlIdentifier id;
SqlNodeList optionList = null;
+ SqlNodeList storageProfiles = null;
}
{
<ZONE> { s.add(this); }
ifNotExists = IfNotExistsOpt()
id = CompoundIdentifier()
- [
- <WITH> { s.add(this); } optionList = CreateZoneOptionList()
- ]
+ (
+ <WITH> { s.add(this); } optionList = CreateZoneOptionList()
+ {
+ return new IgniteSqlCreateZone(s.end(this), ifNotExists, id,
optionList);
+ }
+ |
+ (
+ [ optionList = ZoneOptionsList() ]
+
+ <STORAGE> <PROFILES> {
+ storageProfiles = StorageProfiles();
+ }
+ )
+ {
+ SqlIdentifier key = new
SqlIdentifier(ZoneOptionEnum.STORAGE_PROFILES.name(), getPos());
+ IgniteSqlZoneOption profilesOption = new
IgniteSqlZoneOption(key, storageProfiles, getPos());
+ if (optionList != null) {
+ optionList.add(profilesOption);
+ } else {
+ optionList = SqlNodeList.of(profilesOption);
+ }
+ return new IgniteSqlCreateZone(s.end(this), ifNotExists, id,
optionList);
+ }
+ )
+}
+
+SqlNodeList StorageProfiles() :
+{
+ final Span s = Span.of();
+ final List<SqlNode> list = new ArrayList<SqlNode>();
+}
+{
+ <LBRACKET>
+ StorageProfileOption(list)
+ (
+ <COMMA> { s.add(this); } StorageProfileOption(list)
+ )*
+ <RBRACKET> {
+ return new SqlNodeList(list, s.end(this));
+ }
+}
+
+void StorageProfileOption(List<SqlNode> list) :
+{
+ final SqlCharStringLiteral val;
+}
+{
+ val = UnquotedLiteral() { list.add(val); }
+}
+
+SqlCharStringLiteral UnquotedLiteral() :
Review Comment:
what does `UnquotedLiteral` mean?
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/ddl/DdlSqlToCommandConverter.java:
##########
@@ -699,6 +700,24 @@ private CatalogCommand
convertCreateZone(IgniteSqlCreateZone createZoneNode, Pla
for (SqlNode optionNode : createZoneNode.createOptionList().getList())
{
IgniteSqlZoneOption option = (IgniteSqlZoneOption) optionNode;
+ if (option.key().names.get(0).equals(STORAGE_PROFILES.name())) {
+ if (option.value() instanceof SqlNodeList) {
+ SqlNodeList values = (SqlNodeList) option.value();
+ List<String> profileNames = new ArrayList<>(((SqlNodeList)
option.value()).getList().size());
+
+ SqlCharStringLiteral literal;
+ for (SqlNode node : values) {
+ literal = (SqlCharStringLiteral) node;
+ profileNames.add(literal.getValueAs(String.class));
+ }
+
+ String profilesJoined = String.join(",", profileNames);
Review Comment:
please don't rebuild string just to parse it inside next method call. Change
the option to accept list and only list
##########
modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/sql/DistributionZoneSqlDdlParserTest.java:
##########
@@ -48,48 +47,90 @@ public class DistributionZoneSqlDdlParserTest extends
AbstractParserTest {
@Test
public void createZoneNoOptions() {
Review Comment:
let's derive all createZone test to
`DistributionZoneOldSyntaxSqlDdlParserTest` to make sure nothing is broken
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]