-
Notifications
You must be signed in to change notification settings - Fork 17
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: support annotations in SQL file #171
Conversation
5fe0b0b
to
5656f9a
Compare
Can you add some examples in the 3 files in the test resources -
To verify that these annotations do not break parsing/diff generation - eg changing annotations without changing table definition is a no-op https://github.com/cloudspannerecosystem/spanner-schema-diff-tool/tree/main/src/test/resources |
Added test case to ensure that annotations do not result in diff generation |
I have updated the annotations in the test files to have the comment prefix... |
src/main/java/com/google/cloud/solutions/spannerddl/diff/DdlDiff.java
Outdated
Show resolved
Hide resolved
…omments in the DDL file
Initially I though of adding The export of the parsed DDL is an entirely new feature. The README.md may not be right file to advertise this capability. An additional markdown file may be added to advertise this new capability to have the parse statements available to other Java programs. I am leaving the advertisement to you. |
Yep thats fine.
I have added a comment in the parser jjt code and annotations AST class that this Annotations are not a Spanner feature, but can be used by customers who wish to add metadata to column definitions and use this parser... |
Spanner DDL SQL is often checked into source control. During the CI build there is often need to:
Since Spanner DDL is an important source of truth, it useful to annotate the schema with meta information. One such use case to to support annotations on table columns like:
This concept is similar to Java annotations where tools like javadoc can generated documentation based on the annotations. Some of the use cases of annotations:
Since the
@ANNOTATION
is not a valid SQL statement, it is added as comment in the file. The annotations are parsed into AST and will become part of DatabaseDefinition. There is no delta generation as Spanner does not understand annotations or does not even support comments.The CI build steps can use table column annotation.