Skip to content
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

Pretty print only CREATE TABLE #234

Conversation

apstndb
Copy link
Contributor

@apstndb apstndb commented Dec 19, 2024

This PR changes (*CreateTable).SQL()(and (*Cluster).SQL() and (*CreateRowDeletionPolicy).SQL()``) to pretty print style.

Input( testdata/input/ddl/create_table_for_format_test.sql)

create table if not exists foo (
    foo int64,
    bar float64 not null,
    baz string(255) not null options(allow_commit_timestamp = null),
    qux string(255) not null as (concat(baz, "a")) stored,
    foreign key (foo) references t2 (t2key1),
    constraint fkname foreign key (foo, bar) references t2 (t2key1, t2key2),
    check (foo > 0),
    constraint cname check (bar > 0),
    corge timestamp not null default (current_timestamp())
) primary key (foo),
  interleave in parent foobar,
  row deletion policy ( older_than ( baz, INTERVAL 30 DAY ) )

Parse-Unparsed

CREATE TABLE IF NOT EXISTS foo (
    foo INT64,
    bar FLOAT64 NOT NULL,
    baz STRING(255) NOT NULL OPTIONS (allow_commit_timestamp = null),
    qux STRING(255) NOT NULL AS (concat(baz, "a")) STORED,
    corge TIMESTAMP NOT NULL DEFAULT (current_timestamp()),
    FOREIGN KEY (foo) REFERENCES t2 (t2key1),
    CONSTRAINT fkname FOREIGN KEY (foo, bar) REFERENCES t2 (t2key1, t2key2),
    CHECK (foo > 0),
    CONSTRAINT cname CHECK (bar > 0)
) PRIMARY KEY (foo),
INTERLEAVE IN PARENT foobar,
ROW DELETION POLICY ( OLDER_THAN ( baz, INTERVAL 30 DAY ))

Related issues

Copy link
Collaborator

@makenowjust makenowjust left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you.

@makenowjust makenowjust merged commit 42e487c into cloudspannerecosystem:main Dec 19, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants