-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '2.x' into merge-2.x-after-release
Signed-off-by: Chen Dai <[email protected]>
- Loading branch information
Showing
254 changed files
with
7,763 additions
and
1,570 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
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
21 changes: 21 additions & 0 deletions
21
core/src/main/java/org/opensearch/sql/CatalogSchemaName.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,21 @@ | ||
/* | ||
* | ||
* * Copyright OpenSearch Contributors | ||
* * SPDX-License-Identifier: Apache-2.0 | ||
* | ||
*/ | ||
|
||
package org.opensearch.sql; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public class CatalogSchemaName { | ||
|
||
private final String catalogName; | ||
|
||
private final String schemaName; | ||
|
||
} |
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
78 changes: 78 additions & 0 deletions
78
core/src/main/java/org/opensearch/sql/analysis/CatalogSchemaIdentifierNameResolver.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,78 @@ | ||
/* | ||
* | ||
* * Copyright OpenSearch Contributors | ||
* * SPDX-License-Identifier: Apache-2.0 | ||
* | ||
*/ | ||
|
||
package org.opensearch.sql.analysis; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class CatalogSchemaIdentifierNameResolver { | ||
|
||
public static final String DEFAULT_CATALOG_NAME = "@opensearch"; | ||
public static final String DEFAULT_SCHEMA_NAME = "default"; | ||
public static final String INFORMATION_SCHEMA_NAME = "information_schema"; | ||
|
||
private String catalogName = DEFAULT_CATALOG_NAME; | ||
private String schemaName = DEFAULT_SCHEMA_NAME; | ||
private String identifierName; | ||
|
||
private static final String DOT = "."; | ||
|
||
/** | ||
* Data model for capturing catalog, schema and identifier from | ||
* fully qualifiedName. In the current state, it is used to capture | ||
* CatalogSchemaTable name and CatalogSchemaFunction in case of table | ||
* functions. | ||
* | ||
* @param parts parts of qualifiedName. | ||
* @param allowedCatalogs allowedCatalogs. | ||
*/ | ||
public CatalogSchemaIdentifierNameResolver(List<String> parts, Set<String> allowedCatalogs) { | ||
List<String> remainingParts = captureSchemaName(captureCatalogName(parts, allowedCatalogs)); | ||
identifierName = String.join(DOT, remainingParts); | ||
} | ||
|
||
public String getIdentifierName() { | ||
return identifierName; | ||
} | ||
|
||
public String getCatalogName() { | ||
return catalogName; | ||
} | ||
|
||
public String getSchemaName() { | ||
return schemaName; | ||
} | ||
|
||
|
||
// Capture catalog name and return remaining parts(schema name and table name) | ||
// from the fully qualified name. | ||
private List<String> captureCatalogName(List<String> parts, Set<String> allowedCatalogs) { | ||
if (parts.size() > 1 && allowedCatalogs.contains(parts.get(0)) | ||
|| DEFAULT_CATALOG_NAME.equals(parts.get(0))) { | ||
catalogName = parts.get(0); | ||
return parts.subList(1, parts.size()); | ||
} else { | ||
return parts; | ||
} | ||
} | ||
|
||
// Capture schema name and return the remaining parts(table name ) | ||
// in the fully qualified name. | ||
private List<String> captureSchemaName(List<String> parts) { | ||
if (parts.size() > 1 | ||
&& (DEFAULT_SCHEMA_NAME.equals(parts.get(0)) | ||
|| INFORMATION_SCHEMA_NAME.contains(parts.get(0)))) { | ||
schemaName = parts.get(0); | ||
return parts.subList(1, parts.size()); | ||
} else { | ||
return parts; | ||
} | ||
} | ||
|
||
|
||
} |
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.