-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ob-sql-parser): adapt for OceanBase 4.3.3 #3686
Open
MarkPotato777
wants to merge
11
commits into
dev/obcloud_202409
Choose a base branch
from
lebie_obparser_adapt_ob_433_1011
base: dev/obcloud_202409
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,092
−79
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
54741b6
ob-mysql OBLexer.g4 & OBParser.g4 init
MarkPotato777 f2ca515
fix .g4
MarkPotato777 c6c2815
oboracle OBLexer.g4
MarkPotato777 9f6ebd3
adapte oboracle OBParser.g4
MarkPotato777 8affa3f
fix
MarkPotato777 80e48a1
adapt
MarkPotato777 8f6704f
add unit test cases
MarkPotato777 b0757f4
pmd
MarkPotato777 6982700
pmd
MarkPotato777 64675c3
fix ut
MarkPotato777 f106d44
upgrade ob-sql-parser version
MarkPotato777 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...-parser/src/main/java/com/oceanbase/tools/sqlparser/statement/common/mysql/ArrayType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright (c) 2023 OceanBase. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.oceanbase.tools.sqlparser.statement.common.mysql; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.antlr.v4.runtime.ParserRuleContext; | ||
|
||
import com.oceanbase.tools.sqlparser.statement.BaseStatement; | ||
import com.oceanbase.tools.sqlparser.statement.common.DataType; | ||
|
||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NonNull; | ||
import lombok.Setter; | ||
|
||
/** | ||
* @Author: Lebie | ||
* @Date: 2024/10/14 17:27 | ||
* @Description: [] | ||
*/ | ||
@Getter | ||
@Setter | ||
@EqualsAndHashCode(callSuper = false) | ||
public class ArrayType extends BaseStatement implements DataType { | ||
private final String typeName = "ARRAY"; | ||
private final DataType elementType; | ||
|
||
public ArrayType(@NonNull ParserRuleContext context, @NonNull DataType elementType) { | ||
super(context); | ||
this.elementType = elementType; | ||
} | ||
|
||
public ArrayType(DataType elementType) { | ||
this.elementType = elementType; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return this.typeName; | ||
} | ||
|
||
@Override | ||
public List<String> getArguments() { | ||
return Collections.emptyList(); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
...parser/src/main/java/com/oceanbase/tools/sqlparser/statement/common/mysql/VectorType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (c) 2023 OceanBase. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.oceanbase.tools.sqlparser.statement.common.mysql; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.antlr.v4.runtime.ParserRuleContext; | ||
|
||
import com.oceanbase.tools.sqlparser.statement.BaseStatement; | ||
import com.oceanbase.tools.sqlparser.statement.common.DataType; | ||
|
||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NonNull; | ||
import lombok.Setter; | ||
|
||
/** | ||
* @Author: Lebie | ||
* @Date: 2024/10/14 17:14 | ||
* @Description: [] | ||
*/ | ||
@Getter | ||
@Setter | ||
@EqualsAndHashCode(callSuper = false) | ||
public class VectorType extends BaseStatement implements DataType { | ||
private final String typeName; | ||
private final Integer dimension; | ||
|
||
public VectorType(@NonNull ParserRuleContext context, | ||
@NonNull String typeName, @NonNull Integer dimension) { | ||
super(context); | ||
this.typeName = typeName; | ||
this.dimension = dimension; | ||
} | ||
|
||
public VectorType(@NonNull String typeName, @NonNull Integer dimension) { | ||
this.typeName = typeName; | ||
this.dimension = dimension; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return this.typeName; | ||
} | ||
|
||
@Override | ||
public List<String> getArguments() { | ||
return Collections.singletonList(String.valueOf(this.dimension)); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder builder = new StringBuilder(getName()); | ||
builder.append("(").append(dimension).append(")"); | ||
return builder.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...ser/src/main/java/com/oceanbase/tools/sqlparser/statement/expression/ArrayExpression.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright (c) 2023 OceanBase. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.oceanbase.tools.sqlparser.statement.expression; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import org.antlr.v4.runtime.ParserRuleContext; | ||
|
||
import com.oceanbase.tools.sqlparser.statement.Expression; | ||
|
||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NonNull; | ||
|
||
/** | ||
* @Author: Lebie | ||
* @Date: 2024/10/14 21:00 | ||
* @Description: [] | ||
*/ | ||
@Getter | ||
@EqualsAndHashCode(callSuper = true) | ||
public class ArrayExpression extends BaseExpression { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
private List<Expression> expressions = new ArrayList<>(); | ||
|
||
public ArrayExpression(@NonNull ParserRuleContext context, @NonNull List<Expression> expressions) { | ||
super(context); | ||
this.expressions = expressions; | ||
} | ||
|
||
public ArrayExpression(@NonNull List<Expression> expressions) { | ||
this.expressions = expressions; | ||
} | ||
|
||
@Override | ||
protected String doToString() { | ||
return "[" + this.expressions.stream().map(Object::toString).collect(Collectors.joining(",")) + "]"; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.4.0 may be better, adapting for ob433 is a big feature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
further more, odc should also upgrade the parser's version