├── .gitignore ├── CONTRIBUTING.md ├── LICENSE.txt ├── README.md ├── SECURITY.md ├── deploy.sh ├── example ├── .gitignore ├── pom.xml ├── run.sh └── src │ └── main │ └── java │ └── oracle │ └── pgql │ └── lang │ └── example │ └── Main.java ├── graph-query-ir ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── oracle │ └── pgql │ └── lang │ ├── PgqlException.java │ ├── PreparedStatement.java │ ├── ResultAccess.java │ ├── ResultSet.java │ ├── ResultSetFormatter.java │ ├── ResultSetMetaData.java │ ├── ddl │ ├── CallStatement.java │ └── propertygraph │ │ ├── BaseElementTable.java │ │ ├── BaseGraph.java │ │ ├── CreatePropertyGraph.java │ │ ├── CreateSuperPropertyGraph.java │ │ ├── DropPropertyGraph.java │ │ ├── EdgeTable.java │ │ ├── ElementTable.java │ │ ├── Key.java │ │ ├── Label.java │ │ ├── Property.java │ │ └── VertexTable.java │ ├── editor │ └── completion │ │ ├── PgqlCompletion.java │ │ └── PgqlCompletionContext.java │ ├── ir │ ├── CommonPathExpression.java │ ├── DerivedTable.java │ ├── Direction.java │ ├── ExpAsVar.java │ ├── GraphPattern.java │ ├── GraphQuery.java │ ├── GroupBy.java │ ├── OptionalGraphPattern.java │ ├── OrderBy.java │ ├── OrderByElem.java │ ├── PathFindingGoal.java │ ├── PathMode.java │ ├── PgqlStatement.java │ ├── PgqlUtils.java │ ├── Projection.java │ ├── QueryEdge.java │ ├── QueryExpression.java │ ├── QueryExpressionVisitor.java │ ├── QueryPath.java │ ├── QueryType.java │ ├── QueryVariable.java │ ├── QueryVertex.java │ ├── SchemaQualifiedName.java │ ├── SelectQuery.java │ ├── StatementType.java │ ├── TableExpression.java │ ├── TableExpressionType.java │ ├── VertexPairConnection.java │ ├── modify │ │ ├── AbstractInsertion.java │ │ ├── DeleteClause.java │ │ ├── EdgeInsertion.java │ │ ├── InsertClause.java │ │ ├── Insertion.java │ │ ├── InsertionType.java │ │ ├── Modification.java │ │ ├── ModificationType.java │ │ ├── ModifyQuery.java │ │ ├── SetPropertyExpression.java │ │ ├── Update.java │ │ ├── UpdateClause.java │ │ └── VertexInsertion.java │ └── unnest │ │ ├── OneRowPerEdge.java │ │ ├── OneRowPerMatch.java │ │ ├── OneRowPerStep.java │ │ ├── OneRowPerVertex.java │ │ ├── RowsPerMatch.java │ │ └── RowsPerMatchType.java │ ├── metadata │ ├── AbstractMetadataProvider.java │ ├── BinaryOperation.java │ ├── DataTypeSynonym.java │ ├── EdgeLabel.java │ ├── FunctionSignature.java │ ├── GraphSchema.java │ ├── Label.java │ ├── Property.java │ ├── UnaryOperation.java │ └── VertexLabel.java │ ├── spatial │ ├── Point2D.java │ ├── Point3D.java │ ├── STPreparedStatement.java │ ├── STResultAccess.java │ └── WktParseException.java │ └── util │ ├── AbstractQueryExpressionVisitor.java │ ├── ReplaceExpressions.java │ └── SqlDateTimeFormatter.java ├── install.sh ├── install_on_windows.bat ├── pgql-lang ├── .gitignore ├── pom.xml └── src │ ├── main │ └── java │ │ └── oracle │ │ └── pgql │ │ └── lang │ │ ├── CheckInvalidJavaComment.java │ │ ├── CommonTranslationUtil.java │ │ ├── MetadataToAstUtil.java │ │ ├── Pgql.java │ │ ├── PgqlResult.java │ │ ├── PgqlVersion.java │ │ ├── SpoofaxAstToGraphQuery.java │ │ ├── TranslateCallStatement.java │ │ ├── TranslateCreatePropertyGraph.java │ │ ├── TranslateDropPropertyGraph.java │ │ ├── TranslationContext.java │ │ └── completion │ │ ├── ClauseOrAggregate.java │ │ ├── Function.java │ │ ├── Keyword.java │ │ └── PgqlCompletionGenerator.java │ └── test │ └── java │ └── oracle │ └── pgql │ └── lang │ ├── AbstractPgqlTest.java │ ├── BugFixTest.java │ ├── ExampleMetadataProvider.java │ ├── MetadataTest.java │ ├── PrettyPrintingTest.java │ ├── StaticOptimizationsTest.java │ ├── SyntaxErrorsTest.java │ ├── UniqueNameGenerationTest.java │ ├── completions │ ├── AbstractCompletionsTest.java │ ├── ExpressionCompletionsTest.java │ ├── InputGraphCompletionsTest.java │ ├── KeywordCompletionsTest.java │ ├── LabelCompletionsTest.java │ ├── PatternCompletionsTest.java │ └── PropertyCompletionsTest.java │ └── spatial │ └── Point2DTest.java ├── pgql-spoofax ├── .classpath ├── .gitignore ├── .mvn │ ├── extensions.xml │ ├── jvm.config │ ├── maven.config │ └── settings.xml ├── editor │ ├── Analysis.esv │ ├── Colorer.esv │ ├── Main.esv │ └── Syntax.esv ├── metaborg.yaml ├── pom.xml ├── src │ └── main │ │ └── strategies │ │ └── pgqllang │ │ └── strategies │ │ ├── DateTimeFormatters.java │ │ ├── InteropRegisterer.java │ │ ├── Main.java │ │ ├── has_timezone_0_0.java │ │ ├── is_invalid_datetime_0_0.java │ │ ├── is_invalid_datetime_field_0_0.java │ │ ├── unescape_legacy_identifier_0_0.java │ │ └── unescape_legacy_string_literal_0_0.java ├── syntax │ ├── DDL.sdf3 │ ├── Expressions.sdf3 │ ├── GraphPattern.sdf3 │ ├── Layout.sdf3 │ ├── Legacy.sdf3 │ ├── Literals.sdf3 │ ├── Modify.sdf3 │ ├── Names.sdf3 │ ├── SolutionModifiers.sdf3 │ └── pgql-lang.sdf3 └── trans │ ├── analysis.str │ ├── check.str │ ├── common.str │ ├── name-analysis.str │ ├── names.nab │ ├── normalize-after.str │ ├── normalize-ddl.str │ ├── normalize.str │ ├── normalized-signatures.str │ ├── outline.str │ ├── pgql_lang.str │ ├── pp.str │ └── type-analysis.str ├── pgql-tests ├── .gitignore ├── analysis │ └── derived-tables.spt ├── error-messages │ ├── DDL.spt │ ├── case-insensitivity.spt │ ├── expressions.spt │ ├── graph_table.spt │ ├── grouping-and-aggregating.spt │ ├── having-clause.spt │ ├── legacy │ │ ├── pgql10 │ │ │ ├── disabled-pgql10-features.spt │ │ │ ├── mix-pgql10-and-pgql11.spt │ │ │ └── mix-pgql10-and-pgql13.spt │ │ └── pgql11 │ │ │ └── mix-pgql11-and-pgql13.spt │ ├── modify.spt │ ├── multiple-graphs.spt │ ├── optional-match.spt │ ├── select-variables.spt │ ├── select.spt │ ├── sorting-and-row-limiting.spt │ ├── subqueries.spt │ ├── syntax.spt │ ├── types.spt │ ├── variable-length-paths.spt │ └── variables.spt ├── pom.xml ├── reference-resolution │ ├── basic.spt │ ├── group-variables.spt │ ├── modify.spt │ ├── path-unnesting.spt │ └── subqueries.spt ├── spring-boot-app │ ├── .gitignore │ ├── pom.xml │ ├── run.sh │ └── src │ │ └── main │ │ └── java │ │ └── oracle │ │ └── pgql │ │ └── lang │ │ └── springbootapp │ │ └── Main.java └── syntax │ ├── built-in-functions.spt │ ├── expressions.spt │ ├── grouping-and-aggregating.spt │ ├── limit-offset.spt │ ├── order-by.spt │ ├── pattern-matching.spt │ ├── syntax.spt │ ├── three-valued-logic.spt │ ├── types.spt │ └── variables.spt ├── pgql_home_screenshot.png └── sbom_generation.yaml /.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | /.settings 3 | /.idea/ 4 | pgql-lang-parent.iml 5 | /_site/ 6 | GenerateMenuFromMarkdown.class 7 | pgql-lang/src/main/resources/pgql-spoofax-binaries/ 8 | *.versionsBackup 9 | *.bak 10 | *.aterm 11 | pgql-spoofax/.classpath 12 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to this repository 2 | 3 | We welcome your contributions! There are multiple ways to contribute. 4 | 5 | ## Opening issues 6 | 7 | For bugs or enhancement requests, please file a GitHub issue unless it's 8 | security related. When filing a bug remember that the better written the bug is, 9 | the more likely it is to be fixed. If you think you've found a security 10 | vulnerability, do not raise a GitHub issue and follow the instructions in our 11 | [security policy](./SECURITY.md). 12 | 13 | ## Contributing code 14 | 15 | We welcome your code contributions. Before submitting code via a pull request, 16 | you will need to have signed the [Oracle Contributor Agreement][OCA] (OCA) and 17 | your commits need to include the following line using the name and e-mail 18 | address you used to sign the OCA: 19 | 20 | ```text 21 | Signed-off-by: Your Name 22 | ``` 23 | 24 | This can be automatically added to pull requests by committing with `--sign-off` 25 | or `-s`, e.g. 26 | 27 | ```text 28 | git commit --signoff 29 | ``` 30 | 31 | Only pull requests from committers that can be verified as having signed the OCA 32 | can be accepted. 33 | 34 | ## Pull request process 35 | 36 | 1. Ensure there is an issue created to track and discuss the fix or enhancement 37 | you intend to submit. 38 | 1. Fork this repository. 39 | 1. Create a branch in your fork to implement the changes. We recommend using 40 | the issue number as part of your branch name, e.g. `1234-fixes`. 41 | 1. Ensure that any documentation is updated with the changes that are required 42 | by your change. 43 | 1. Ensure that any samples are updated if the base image has been changed. 44 | 1. Submit the pull request. *Do not leave the pull request blank*. Explain exactly 45 | what your changes are meant to do and provide simple steps on how to validate. 46 | your changes. Ensure that you reference the issue you created as well. 47 | 1. We will assign the pull request to 2-3 people for review before it is merged. 48 | 49 | ## Code of conduct 50 | 51 | Follow the [Golden Rule](https://en.wikipedia.org/wiki/Golden_Rule). If you'd 52 | like more specific guidelines, see the [Contributor Covenant Code of Conduct][COC]. 53 | 54 | [OCA]: https://oca.opensource.oracle.com 55 | [COC]: https://www.contributor-covenant.org/version/1/4/code-of-conduct/ 56 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Reporting security vulnerabilities 2 | 3 | Oracle values the independent security research community and believes that 4 | responsible disclosure of security vulnerabilities helps us ensure the security 5 | and privacy of all our users. 6 | 7 | Please do NOT raise a GitHub Issue to report a security vulnerability. If you 8 | believe you have found a security vulnerability, please submit a report to 9 | [secalert_us@oracle.com][1] preferably with a proof of concept. Please review 10 | some additional information on [how to report security vulnerabilities to Oracle][2]. 11 | We encourage people who contact Oracle Security to use email encryption using 12 | [our encryption key][3]. 13 | 14 | We ask that you do not use other channels or contact the project maintainers 15 | directly. 16 | 17 | Non-vulnerability related security issues including ideas for new or improved 18 | security features are welcome on GitHub Issues. 19 | 20 | ## Security updates, alerts and bulletins 21 | 22 | Security updates will be released on a regular cadence. Many of our projects 23 | will typically release security fixes in conjunction with the 24 | Oracle Critical Patch Update program. Additional 25 | information, including past advisories, is available on our [security alerts][4] 26 | page. 27 | 28 | ## Security-related information 29 | 30 | We will provide security related information such as a threat model, considerations 31 | for secure use, or any known security issues in our documentation. Please note 32 | that labs and sample code are intended to demonstrate a concept and may not be 33 | sufficiently hardened for production use. 34 | 35 | [1]: mailto:secalert_us@oracle.com 36 | [2]: https://www.oracle.com/corporate/security-practices/assurance/vulnerability/reporting.html 37 | [3]: https://www.oracle.com/security-alerts/encryptionkey.html 38 | [4]: https://www.oracle.com/security-alerts/ 39 | -------------------------------------------------------------------------------- /deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | FILES=" 5 | graph-query-ir/pom.xml 6 | pgql-lang/pom.xml 7 | " 8 | 9 | if [ $# -eq 0 ] 10 | then 11 | echo "ERROR: Please specify a version number, for example, 'bash deploy.sh 2017-01-01'." 12 | exit 13 | fi 14 | 15 | if [ -f pgql-lang/src/main/resources/sdf.tbl ] 16 | then 17 | echo "INFO: Using the parser that was previously built via 'bash install.sh'" 18 | else 19 | echo "ERROR: Run 'bash install.sh' first." 20 | exit 21 | fi 22 | 23 | STAGE=false 24 | if [[ "$1" =~ ^[0-9.]+$ ]] 25 | then 26 | echo "Deploying to release repo" 27 | REPO="https://artifacthub-iad.oci.oraclecorp.com/graph-onprem-release-local" 28 | else 29 | echo "Deploying to staging repo" 30 | STAGE=true 31 | REPO="https://artifacthub-iad.oci.oraclecorp.com/graph-onprem-stage-local" 32 | fi 33 | 34 | VERSION_A="0.0.0-SNAPSHOT" 35 | VERSION_B="$1" 36 | 37 | for f in $FILES 38 | do 39 | sed -i.bak "s/$VERSION_A/$VERSION_B/g" $f 40 | if $STAGE 41 | then sed -i.bak "s/release-local/stage-local/g" $f 42 | fi 43 | done 44 | 45 | mvn deploy:deploy-file \ 46 | -DgroupId=oracle.pg \ 47 | -DartifactId=pgql-lang-trans \ 48 | -Dversion=$VERSION_B \ 49 | -Dpackaging=jar \ 50 | -Dfile=pgql-lang/pgql-lang-trans.jar \ 51 | -Durl=$REPO \ 52 | -DrepositoryId=graph-onprem 53 | mvn org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file \ 54 | -Dfile=pgql-lang/pgql-lang-trans.jar \ 55 | -DgroupId=oracle.pg \ 56 | -DartifactId=pgql-lang-trans \ 57 | -Dversion=$VERSION_B \ 58 | -Dpackaging=jar \ 59 | -DlocalRepositoryPath="$(pwd)/pgql-lang/repo/" 60 | cd graph-query-ir/; mvn deploy; cd ../ 61 | cd pgql-lang/; mvn deploy; cd ../ 62 | 63 | for f in $FILES 64 | do 65 | sed -i.bak "s/$VERSION_B/$VERSION_A/g" $f 66 | if $STAGE 67 | then sed -i.bak "s/stage-local/release-local/g" $f 68 | fi 69 | done 70 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.classpath 3 | /.project 4 | /.settings 5 | -------------------------------------------------------------------------------- /example/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | oracle.pg 6 | example 7 | 1.0.0 8 | 9 | 10 | 11 | oracle.pg 12 | pgql-lang 13 | 0.0.0-SNAPSHOT 14 | compile 15 | 16 | 17 | 18 | 19 | 1.8 20 | 1.8 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /example/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export MAVEN_OPTS="-Xms512m -Xmx1024m -Xss16m $MAVEN_OPTS" 4 | 5 | mvn clean package exec:java -Dexec.mainClass="oracle.pgql.lang.example.Main" -Dexec.cleanupDaemonThreads=false 6 | -------------------------------------------------------------------------------- /example/src/main/java/oracle/pgql/lang/example/Main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 - 2023 Oracle and/or its affiliates. All rights reserved. 3 | */ 4 | package oracle.pgql.lang.example; 5 | 6 | import oracle.pgql.lang.PgqlException; 7 | import oracle.pgql.lang.Pgql; 8 | import oracle.pgql.lang.PgqlResult; 9 | 10 | public class Main { 11 | 12 | public static void main(String[] args) throws PgqlException { 13 | 14 | try (Pgql pgql = new Pgql()) { 15 | 16 | // parse query and print graph query 17 | PgqlResult result1 = pgql.parse("SELECT n FROM MATCH (n IS Person) -[e IS likes]-> (m IS Person) WHERE n.name = 'Dave'"); 18 | System.out.println(result1.getPgqlStatement()); 19 | 20 | // parse query with errors and print error messages 21 | PgqlResult result2 = pgql.parse("SELECT x, y FROM MATCH (n) -[e]-> (m)"); 22 | System.out.println(result2.getErrorMessages()); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /graph-query-ir/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /target/ 3 | /.classpath 4 | /.project 5 | /.settings 6 | /graph-query-ir.iml 7 | /.idea/ 8 | -------------------------------------------------------------------------------- /graph-query-ir/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | oracle.pg 6 | graph-query-ir 7 | 0.0.0-SNAPSHOT 8 | 9 | jar 10 | 11 | 12 | 1.8 13 | 1.8 14 | 15 | 16 | 17 | 18 | 19 | org.apache.maven.plugins 20 | maven-jar-plugin 21 | 22 | 23 | 24 | true 25 | 26 | 27 | 28 | 29 | 30 | org.apache.maven.plugins 31 | maven-source-plugin 32 | 33 | 34 | attach-sources 35 | 36 | jar 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | graph-onprem 47 | Oracle Internal Repository 48 | https://artifacthub-iad.oci.oraclecorp.com/graph-onprem-release-local 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /graph-query-ir/src/main/java/oracle/pgql/lang/PgqlException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 - 2023 Oracle and/or its affiliates. All rights reserved. 3 | */ 4 | package oracle.pgql.lang; 5 | 6 | public class PgqlException extends Exception { 7 | 8 | public PgqlException(Throwable cause) { 9 | super(cause); 10 | } 11 | 12 | public PgqlException(String msg) { 13 | super(msg); 14 | } 15 | 16 | public PgqlException(String msg, Throwable cause) { 17 | super(msg, cause); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /graph-query-ir/src/main/java/oracle/pgql/lang/ResultSetMetaData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 - 2023 Oracle and/or its affiliates. All rights reserved. 3 | */ 4 | package oracle.pgql.lang; 5 | 6 | public interface ResultSetMetaData { 7 | 8 | /** 9 | * Returns the number of columns in this ResultSet object. 10 | * 11 | * @return the number of columns 12 | */ 13 | public int getColumnCount(); 14 | 15 | /** 16 | * Get the designated column's name. 17 | * 18 | * @param column the first column is 1, the second is 2, ... 19 | * @return column name 20 | */ 21 | public String getColumnName(int column); 22 | } 23 | -------------------------------------------------------------------------------- /graph-query-ir/src/main/java/oracle/pgql/lang/ddl/propertygraph/BaseElementTable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 - 2023 Oracle and/or its affiliates. All rights reserved. 3 | */ 4 | package oracle.pgql.lang.ddl.propertygraph; 5 | 6 | import static oracle.pgql.lang.ir.PgqlUtils.printIdentifier; 7 | 8 | public class BaseElementTable { 9 | 10 | private String referencedTableName; 11 | 12 | /** 13 | * Never null since the PGQL parser defaults the alias to the referenced element table name in case no alias is specified. 14 | */ 15 | private String tableAlias; 16 | 17 | public BaseElementTable(String referencedTableName, String tableAlias) { 18 | this.referencedTableName = referencedTableName; 19 | this.tableAlias = tableAlias; 20 | } 21 | 22 | public String getReferencedTableName() { 23 | return referencedTableName; 24 | } 25 | 26 | public void setReferencedTableName(String referencedTableName) { 27 | this.referencedTableName = referencedTableName; 28 | } 29 | 30 | public String getTableAlias() { 31 | return tableAlias; 32 | } 33 | 34 | public void setTableAlias(String tableAlias) { 35 | this.tableAlias = tableAlias; 36 | } 37 | 38 | @Override 39 | public String toString() { 40 | return printIdentifier(referencedTableName) 41 | + (referencedTableName.equals(tableAlias) ? "" : " AS " + printIdentifier(tableAlias)); 42 | } 43 | 44 | @Override 45 | public int hashCode() { 46 | return 31; 47 | } 48 | 49 | @Override 50 | public boolean equals(Object obj) { 51 | if (this == obj) 52 | return true; 53 | if (obj == null) 54 | return false; 55 | if (getClass() != obj.getClass()) 56 | return false; 57 | BaseElementTable other = (BaseElementTable) obj; 58 | if (referencedTableName == null) { 59 | if (other.referencedTableName != null) 60 | return false; 61 | } else if (!referencedTableName.equals(other.referencedTableName)) 62 | return false; 63 | if (tableAlias == null) { 64 | if (other.tableAlias != null) 65 | return false; 66 | } else if (!tableAlias.equals(other.tableAlias)) 67 | return false; 68 | return true; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /graph-query-ir/src/main/java/oracle/pgql/lang/ddl/propertygraph/BaseGraph.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 - 2023 Oracle and/or its affiliates. All rights reserved. 3 | */ 4 | package oracle.pgql.lang.ddl.propertygraph; 5 | 6 | import java.util.List; 7 | import java.util.stream.Collectors; 8 | 9 | import oracle.pgql.lang.ir.SchemaQualifiedName; 10 | 11 | import static oracle.pgql.lang.ir.PgqlUtils.printIdentifier; 12 | 13 | public class BaseGraph { 14 | 15 | private SchemaQualifiedName graphName; 16 | 17 | /** 18 | * This field is null unless the user specified ELEMENT TABLES ( .. ) 19 | */ 20 | private List baseElementTables; 21 | 22 | /** 23 | * This field is null unless the user specified ALL ELEMENT TABLES EXCEPT ( .. ) 24 | */ 25 | private List allElementTablesExcept; 26 | 27 | public BaseGraph(SchemaQualifiedName graphName, List baseElementTables, 28 | List allElementTablesExcept) { 29 | this.graphName = graphName; 30 | this.baseElementTables = baseElementTables; 31 | this.allElementTablesExcept = allElementTablesExcept; 32 | } 33 | 34 | public SchemaQualifiedName getGraphName() { 35 | return graphName; 36 | } 37 | 38 | public void setGraphName(SchemaQualifiedName graphName) { 39 | this.graphName = graphName; 40 | } 41 | 42 | public List getBaseElementTables() { 43 | return baseElementTables; 44 | } 45 | 46 | public void setBaseElementTables(List baseElementTables) { 47 | this.baseElementTables = baseElementTables; 48 | } 49 | 50 | public List getAllElementTablesExcept() { 51 | return allElementTablesExcept; 52 | } 53 | 54 | public void setAllElementTablesExcept(List allElementTablesExcept) { 55 | this.allElementTablesExcept = allElementTablesExcept; 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | String result = graphName.toString(true); 61 | if (baseElementTables != null) { 62 | result += " ELEMENT TABLES ( " // 63 | + baseElementTables.stream().map(x -> x.toString()).collect(Collectors.joining(", ")) // 64 | + ")"; 65 | } else if (allElementTablesExcept != null) { 66 | result += " ALL ELEMENT TABLES EXCEPT ( " // 67 | + allElementTablesExcept.stream().map(x -> printIdentifier(x)).collect(Collectors.joining(", ")) // 68 | + " )"; 69 | } else { 70 | result += " ALL ELEMENT TABLES"; 71 | } 72 | 73 | return result; 74 | } 75 | 76 | @Override 77 | public int hashCode() { 78 | return 31; 79 | } 80 | 81 | @Override 82 | public boolean equals(Object obj) { 83 | if (this == obj) 84 | return true; 85 | if (obj == null) 86 | return false; 87 | if (getClass() != obj.getClass()) 88 | return false; 89 | BaseGraph other = (BaseGraph) obj; 90 | if (allElementTablesExcept == null) { 91 | if (other.allElementTablesExcept != null) 92 | return false; 93 | } else if (!allElementTablesExcept.equals(other.allElementTablesExcept)) 94 | return false; 95 | if (baseElementTables == null) { 96 | if (other.baseElementTables != null) 97 | return false; 98 | } else if (!baseElementTables.equals(other.baseElementTables)) 99 | return false; 100 | if (graphName == null) { 101 | if (other.graphName != null) 102 | return false; 103 | } else if (!graphName.equals(other.graphName)) 104 | return false; 105 | return true; 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /graph-query-ir/src/main/java/oracle/pgql/lang/ddl/propertygraph/CreateSuperPropertyGraph.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 - 2023 Oracle and/or its affiliates. All rights reserved. 3 | */ 4 | package oracle.pgql.lang.ddl.propertygraph; 5 | 6 | import java.util.List; 7 | import java.util.stream.Collectors; 8 | 9 | import oracle.pgql.lang.ir.SchemaQualifiedName; 10 | import oracle.pgql.lang.ir.StatementType; 11 | 12 | public class CreateSuperPropertyGraph extends CreatePropertyGraph { 13 | 14 | private List baseGraphs; 15 | 16 | public CreateSuperPropertyGraph(SchemaQualifiedName graphName, List baseGraphs, 17 | List vertexTables, List edgeTables) { 18 | super(graphName, vertexTables, edgeTables); 19 | this.baseGraphs = baseGraphs; 20 | } 21 | 22 | public List getBaseGraphs() { 23 | return baseGraphs; 24 | } 25 | 26 | public void setBaseGraphs(List baseGraphs) { 27 | this.baseGraphs = baseGraphs; 28 | } 29 | 30 | @Override 31 | public String toString() { 32 | return "CREATE PROPERTY GRAPH " + graphName.toString(true) // 33 | + "\n BASE GRAPHS (\n " + baseGraphs.stream().map(x -> x.toString()).collect(Collectors.joining(",\n ")) + "\n )" // 34 | + printVertexTables() + printEdgeTables() + printOptions(); 35 | } 36 | 37 | @Override 38 | public StatementType getStatementType() { 39 | return StatementType.CREATE_SUPER_PROPERTY_GRAPH; 40 | } 41 | 42 | @Override 43 | public int hashCode() { 44 | return 31; 45 | } 46 | 47 | @Override 48 | public boolean equals(Object obj) { 49 | if (this == obj) 50 | return true; 51 | if (!super.equals(obj)) 52 | return false; 53 | if (getClass() != obj.getClass()) 54 | return false; 55 | CreateSuperPropertyGraph other = (CreateSuperPropertyGraph) obj; 56 | if (baseGraphs == null) { 57 | if (other.baseGraphs != null) 58 | return false; 59 | } else if (!baseGraphs.equals(other.baseGraphs)) 60 | return false; 61 | return true; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /graph-query-ir/src/main/java/oracle/pgql/lang/ddl/propertygraph/DropPropertyGraph.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 - 2023 Oracle and/or its affiliates. All rights reserved. 3 | */ 4 | package oracle.pgql.lang.ddl.propertygraph; 5 | 6 | import oracle.pgql.lang.ir.SchemaQualifiedName; 7 | import oracle.pgql.lang.ir.PgqlStatement; 8 | import oracle.pgql.lang.ir.StatementType; 9 | 10 | public class DropPropertyGraph implements PgqlStatement { 11 | 12 | private SchemaQualifiedName schemaName; 13 | 14 | public DropPropertyGraph(SchemaQualifiedName graphName) { 15 | this.schemaName = graphName; 16 | } 17 | 18 | public SchemaQualifiedName getGraphName() { 19 | return schemaName; 20 | } 21 | 22 | public void setGraphName(SchemaQualifiedName graphName) { 23 | this.schemaName = graphName; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return "DROP PROPERTY GRAPH " + schemaName.toString(true); 29 | } 30 | 31 | @Override 32 | public StatementType getStatementType() { 33 | return StatementType.DROP_PROPERTY_GRAPH; 34 | } 35 | 36 | @Override 37 | public int hashCode() { 38 | return 31; 39 | } 40 | 41 | @Override 42 | public boolean equals(Object obj) { 43 | if (this == obj) 44 | return true; 45 | if (obj == null) 46 | return false; 47 | if (getClass() != obj.getClass()) 48 | return false; 49 | DropPropertyGraph other = (DropPropertyGraph) obj; 50 | if (schemaName == null) { 51 | if (other.schemaName != null) 52 | return false; 53 | } else if (!schemaName.equals(other.schemaName)) 54 | return false; 55 | return true; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /graph-query-ir/src/main/java/oracle/pgql/lang/ddl/propertygraph/Key.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 - 2023 Oracle and/or its affiliates. All rights reserved. 3 | */ 4 | package oracle.pgql.lang.ddl.propertygraph; 5 | 6 | import java.util.List; 7 | import java.util.stream.Collectors; 8 | 9 | import static oracle.pgql.lang.ir.PgqlUtils.printIdentifier; 10 | 11 | public class Key { 12 | 13 | /** 14 | * The column that make up the key. 15 | */ 16 | List columnNames; 17 | 18 | /** 19 | * The constructor. 20 | */ 21 | public Key(List columnNames) { 22 | this.columnNames = columnNames; 23 | } 24 | 25 | public List getColumnNames() { 26 | return columnNames; 27 | } 28 | 29 | public void setColumnNames(List columnNames) { 30 | this.columnNames = columnNames; 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return "( " + columnNames.stream() // 36 | .map(x -> printIdentifier(x)) // 37 | .collect(Collectors.joining(", ")) + " )"; 38 | } 39 | 40 | @Override 41 | public int hashCode() { 42 | return 31; 43 | } 44 | 45 | @Override 46 | public boolean equals(Object obj) { 47 | if (this == obj) 48 | return true; 49 | if (obj == null) 50 | return false; 51 | if (getClass() != obj.getClass()) 52 | return false; 53 | Key other = (Key) obj; 54 | if (columnNames == null) { 55 | if (other.columnNames != null) 56 | return false; 57 | } else if (!columnNames.equals(other.columnNames)) 58 | return false; 59 | return true; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /graph-query-ir/src/main/java/oracle/pgql/lang/ddl/propertygraph/Property.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 - 2023 Oracle and/or its affiliates. All rights reserved. 3 | */ 4 | package oracle.pgql.lang.ddl.propertygraph; 5 | 6 | import static oracle.pgql.lang.ir.PgqlUtils.printIdentifier; 7 | 8 | import oracle.pgql.lang.ir.QueryExpression; 9 | import oracle.pgql.lang.ir.QueryExpression.ExpressionType; 10 | import oracle.pgql.lang.ir.QueryExpression.VarRef; 11 | 12 | public class Property { 13 | 14 | /** 15 | * The value expression. 16 | */ 17 | QueryExpression valueExpression; 18 | 19 | /** 20 | * The property name. 21 | */ 22 | String propertyName; 23 | 24 | /** 25 | * Constructor with column name and property name. 26 | */ 27 | public Property(QueryExpression valueExpression, String propertyName) { 28 | this.valueExpression = valueExpression; 29 | this.propertyName = propertyName; 30 | } 31 | 32 | public QueryExpression getValueExpression() { 33 | return valueExpression; 34 | } 35 | 36 | public void setValueExpression(QueryExpression valueExpression) { 37 | this.valueExpression = valueExpression; 38 | } 39 | 40 | public String getPropertyName() { 41 | return propertyName; 42 | } 43 | 44 | public void setPropertyName(String propertyName) { 45 | this.propertyName = propertyName; 46 | } 47 | 48 | /** 49 | * @deprecated use getValueExpression() instead 50 | */ 51 | @Deprecated 52 | public String getColumnName() { 53 | if (valueExpression.getExpType() == ExpressionType.VARREF) { 54 | VarRef varRef = (VarRef) valueExpression; 55 | return varRef.getVariable().getName(); 56 | } else { 57 | return null; 58 | } 59 | } 60 | 61 | @Override 62 | public String toString() { 63 | if (getColumnName() != null && getColumnName().equals(propertyName)) { 64 | return printIdentifier(propertyName); 65 | } else { 66 | return valueExpression + " AS " + printIdentifier(propertyName); 67 | } 68 | } 69 | 70 | @Override 71 | public int hashCode() { 72 | return 31; 73 | } 74 | 75 | @Override 76 | public boolean equals(Object obj) { 77 | if (this == obj) 78 | return true; 79 | if (obj == null) 80 | return false; 81 | if (getClass() != obj.getClass()) 82 | return false; 83 | Property other = (Property) obj; 84 | if (propertyName == null) { 85 | if (other.propertyName != null) 86 | return false; 87 | } else if (!propertyName.equals(other.propertyName)) 88 | return false; 89 | if (valueExpression == null) { 90 | if (other.valueExpression != null) 91 | return false; 92 | } else if (!valueExpression.equals(other.valueExpression)) 93 | return false; 94 | return true; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /graph-query-ir/src/main/java/oracle/pgql/lang/ddl/propertygraph/VertexTable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 - 2023 Oracle and/or its affiliates. All rights reserved. 3 | */ 4 | package oracle.pgql.lang.ddl.propertygraph; 5 | 6 | import java.util.List; 7 | 8 | import oracle.pgql.lang.ir.SchemaQualifiedName; 9 | 10 | public class VertexTable extends ElementTable { 11 | 12 | /** 13 | * Constructor without alias. 14 | */ 15 | public VertexTable(SchemaQualifiedName tableName, Key key, List