This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PPL] Create ANTLR parser and implement basic syntax - Phase0 (#429)
* m * Added antlr files * Added wildcard * Implemented parser for commands of simple syntax * addressed comments * Enabled parsing nested fields and arrays in field * Added unit tests for nested fields * Added Java doc for classes * Replaced the imported parser with static methods in the parser * Addressed comments * Addressed comments * Addressed comments * changed LogicalPlan to UnresolvedPlan; added test for index name with dots; changed the funcName to String in Function expression * Reverted nest * Removed constant and replaced it with literalValue in antlr parser * Simplified the accept methods * Update * Added builder pattern * Rolled back to remove builder * update * Revert "Added builder pattern" This reverts commit acb1575 * update
- Loading branch information
Showing
31 changed files
with
1,956 additions
and
71 deletions.
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
44 changes: 44 additions & 0 deletions
44
common/src/main/java/com/amazon/opendistroforelasticsearch/sql/common/utils/StringUtils.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,44 @@ | ||
/* | ||
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file 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.amazon.opendistroforelasticsearch.sql.common.utils; | ||
|
||
import com.google.common.base.Strings; | ||
|
||
public class StringUtils { | ||
/** | ||
* @param text string | ||
* @param mark quotation mark | ||
* @return An unquoted string whose outer pair of (single/double/back-tick) quotes have been removed | ||
*/ | ||
public static String unquoteIdentifier(String text, String mark) { | ||
if (isQuoted(text, mark)) { | ||
return text.substring(mark.length(), text.length() - mark.length()); | ||
} | ||
return text; | ||
} | ||
|
||
public static String unquoteIdentifier(String text) { | ||
if (isQuoted(text, "\"") || isQuoted(text, "'") || isQuoted(text, "`")) { | ||
return text.substring(1, text.length() - 1); | ||
} else { | ||
return text; | ||
} | ||
} | ||
|
||
private static boolean isQuoted(String text, String mark) { | ||
return !Strings.isNullOrEmpty(text) && text.startsWith(mark) && text.endsWith(mark); | ||
} | ||
} |
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
Oops, something went wrong.