{"id":42482626,"url":"https://github.com/cloudspannerecosystem/spanner-cassandra-schema-tool","last_synced_at":"2026-01-28T11:15:47.818Z","repository":{"id":286010875,"uuid":"960036446","full_name":"cloudspannerecosystem/spanner-cassandra-schema-tool","owner":"cloudspannerecosystem","description":"CLI tool to streamline Cassandra to Spanner schema migration","archived":false,"fork":false,"pushed_at":"2025-05-07T22:50:13.000Z","size":159,"stargazers_count":1,"open_issues_count":5,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-07T23:29:25.301Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloudspannerecosystem.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-03T18:53:49.000Z","updated_at":"2025-05-07T22:50:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"cb49fae6-b39e-40e9-a0f5-66cb6e1a30e7","html_url":"https://github.com/cloudspannerecosystem/spanner-cassandra-schema-tool","commit_stats":null,"previous_names":["cloudspannerecosystem/spanner-cassandra-schema-tool"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cloudspannerecosystem/spanner-cassandra-schema-tool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudspannerecosystem%2Fspanner-cassandra-schema-tool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudspannerecosystem%2Fspanner-cassandra-schema-tool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudspannerecosystem%2Fspanner-cassandra-schema-tool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudspannerecosystem%2Fspanner-cassandra-schema-tool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloudspannerecosystem","download_url":"https://codeload.github.com/cloudspannerecosystem/spanner-cassandra-schema-tool/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudspannerecosystem%2Fspanner-cassandra-schema-tool/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28844862,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T10:53:21.605Z","status":"ssl_error","status_checked_at":"2026-01-28T10:53:20.789Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-28T11:15:46.886Z","updated_at":"2026-01-28T11:15:47.812Z","avatar_url":"https://github.com/cloudspannerecosystem.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spanner Cassandra Schema Tool\n\nThis CLI tool streamlines Cassandra to Spanner schema migration by automating the following key steps:\n1. **CQL Parsing:** Read Cassandra DDL from a specified CQL file.\n2. **CQL Translation:** Translate Cassandra DDL into equivalent Spanner DDL.\n3. **Schema Export:** Dump the generated Spanner schema to the `schema.txt` file for review and manual application if needed.\n4. **Apply schema to Spanner Database (Optional):** Directly connects to your target Spanner database and applies the generated schema.\n\n[Core conecpts](https://cloud.google.com/spanner/docs/non-relational/spanner-for-cassandra-users#core_concepts) you need to know before using this tool:\n* The concept of a Cassandra keyspace is directly equivalent to a Spanner database. Therefore, when converting the DDL, the target Spanner database serves as the implicit keyspace. Imagine that selecting a Spanner database is akin to having created a keyspace with the same name and then executing a USE statement for it. Any keyspace specified within a CQL statement being translated must be identical to the name of the Spanner database you are actively using.\n\n## Note on the DDL Translation\n\n* Only `CREATE TABLE` statements are processed. Other statements are ignored.\n* Table options in the `CREATE TABLE` statements are silently ignored.\n* Static columns are not supported (syntax error).\n* The following data types are not supported (syntax error): `Duration`, `Tuple`, and `Frozen`.\n* Mapping of [Cassandra native type](https://cassandra.apache.org/doc/stable/cassandra/cql/types.html#native-types) to [Spanner Type](https://cloud.google.com/spanner/docs/reference/standard-sql/data-types#data_type_list):\n    | Cassandra | Spanner    |\n    | --------- | ---------- |\n    | BIGINT    | INT64      |\n    | INT       | INT64      |\n    | SMALLINT  | INT64      |\n    | TINYINT   | INT64      |\n    | TIME      | INT64      |\n    | COUNTER   | INT64      |\n    | ASCII     | STRING(MAX)|\n    | TEXT      | STRING(MAX)|\n    | VARCHAR   | STRING(MAX)|\n    | INET      | STRING(MAX)|\n    | UUID      | STRING(MAX)|\n    | TIMEUUID  | STRING(MAX)|\n    | BOOLEAN   | BOOL       |\n    | TIMESTAMP | TIMESTAMP  |\n    | DATE      | DATE       |\n    | FLOAT     | FLOAT32    |\n    | DOUBLE    | FLOAT64    |\n    | DECIMAL   | NUMERIC    |\n    | VARINT    | NUMERIC    |\n    | BLOB      | BYTES(MAX) |\n\n* Mapping of [Cassandra collection type](https://cassandra.apache.org/doc/stable/cassandra/cql/types.html#collections) to [Spanner Type](https://cloud.google.com/spanner/docs/reference/standard-sql/data-types#data_type_list):\n    | Cassandra  | Spanner      |\n    | ---------- | ------------ |\n    | LIST\\\u003ccassandra_type\\\u003e | ARRAY\\\u003cspanner_type\\\u003e  |\n    | SET\\\u003ccassandra_type\\\u003e  | ARRAY\\\u003cspanner_type\\\u003e  |\n    | MAP\u003ctype, type\u003e | JSON    |\n\n* The original Cassandra type will be added to the options in each column definition in the translated `CREATE TABLE` statement. See the example section below for details.\n* Cassandra (composite) partition key and clustering columns are combined to form the composite primary key in Spanner. See the example section below for details.\n* The translation process primarily focuses on **data type** and **primary key clause** conversion. It **does not** gurantee comprehensive semantic validation of the DDL.\n\n## Requirements\n\n- **Go**: Ensure that Go is installed on your system. The required go version is 1.23+.\n- **Google Cloud SDK**: Ensure `gcloud` is installed and authenticated with proper permissions.\n- **Spanner Database**: Ensure the target Spanner database is created.\n\n## Setup\n\n### Clone the Repository\n\n```bash\ngit clone https://github.com/cloudspannerecosystem/spanner-cassandra-schema-tool.git\ncd spanner-cassandra-schema-tool\n```\n\n### Install Dependencies\n\nEnsure that all necessary Go modules are installed:\n\n```bash\ngo mod download\n```\n\n### Set Up Google Cloud Credentials\n\nThis tool uses [Application Default Credentials](https://cloud.google.com/docs/authentication/production?hl=en#providing_credentials_to_your_application) as the credential source for connecting to Spanner databases. Set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable to the path of your service account key file.\n\n```bash\nexport GOOGLE_APPLICATION_CREDENTIALS=\"/path/to/your/service-account-file.json\"\n```\n\n## Usage\n\n### SYNOPSIS\n\n```bash\ngo run schema_converter.go \\\n    --project \u003cPROJECT_ID\u003e \\\n    --instance \u003cINSTANCE_ID\u003e \\\n    --database \u003cDATABASE_ID\u003e \\\n    --cql \u003cPATH_TO_CQL_FILE\u003e \\\n    [--dry-run]\n```\n\n- `--project`: Google Cloud project ID.\n- `--instance`: Spanner instance ID.\n- `--database`: Spanner database ID.\n- `--cql`: Path to the CQL file containing DDL statements.\n- `[--dry-run]`: Output the converted DDL statements without applying to the Spanner database. This flag is optional.\n\n### EXAMPLE\n\n#### Command\n```bash\ngo run schema_converter.go \\\n    --project cassandra-to-spanner \\\n    --instance spanner-instance-dev \\\n    --database testdb \\\n    --cql /path/to/cql-file.cql \\\n    --dry-run\n```\n\n#### Cassandra DDL in the input CQL file\n```sql\nCREATE TABLE IF NOT EXISTS testdb.example_table (\n    id UUID PRIMARY KEY,\n    ascii_value ASCII,\n    bigint_value BIGINT,\n    blob_value BLOB,\n    boolean_value BOOLEAN,\n    decimal_value DECIMAL,\n    double_value DOUBLE,\n    float_value FLOAT,\n    inet_value INET,\n    int_value INT,\n    smallint_value SMALLINT,\n    text_value TEXT,\n    timestamp_value TIMESTAMP,\n    timeuuid_value TIMEUUID,\n    tinyint_value TINYINT,\n    varchar_value VARCHAR,\n    varint_value VARINT,\n    list_value LIST\u003cTEXT\u003e,\n    map_value MAP\u003cTEXT, INT\u003e,\n    set_value SET\u003cUUID\u003e,\n    date_value DATE,\n    time_value TIME\n);\n\nCREATE TABLE IF NOT EXISTS sensor_data (\n    sensor_id UUID,\n    reading_time TIMESTAMP,\n    location TEXT,\n    temperature DECIMAL,\n    humidity DECIMAL,\n    pressure DECIMAL,\n    PRIMARY KEY ((sensor_id, location), reading_time)\n);\n```\n\n#### Spanner DDL in the output `schema.txt` file\n```sql\nCREATE TABLE IF NOT EXISTS example_table (\n id STRING(MAX) NOT NULL OPTIONS (cassandra_type = 'uuid'),\n ascii_value STRING(MAX) OPTIONS (cassandra_type = 'ascii'),\n bigint_value INT64 OPTIONS (cassandra_type = 'bigint'),\n blob_value BYTES(MAX) OPTIONS (cassandra_type = 'blob'),\n boolean_value BOOL OPTIONS (cassandra_type = 'boolean'),\n decimal_value NUMERIC OPTIONS (cassandra_type = 'decimal'),\n double_value FLOAT64 OPTIONS (cassandra_type = 'double'),\n float_value FLOAT32 OPTIONS (cassandra_type = 'float'),\n inet_value STRING(MAX) OPTIONS (cassandra_type = 'inet'),\n int_value INT64 OPTIONS (cassandra_type = 'int'),\n smallint_value INT64 OPTIONS (cassandra_type = 'smallint'),\n text_value STRING(MAX) OPTIONS (cassandra_type = 'text'),\n timestamp_value TIMESTAMP OPTIONS (cassandra_type = 'timestamp'),\n timeuuid_value STRING(MAX) OPTIONS (cassandra_type = 'timeuuid'),\n tinyint_value INT64 OPTIONS (cassandra_type = 'tinyint'),\n varchar_value STRING(MAX) OPTIONS (cassandra_type = 'varchar'),\n varint_value NUMERIC OPTIONS (cassandra_type = 'varint'),\n list_value ARRAY\u003cSTRING(MAX)\u003e OPTIONS (cassandra_type = 'list\u003ctext\u003e'),\n map_value JSON OPTIONS (cassandra_type = 'map\u003ctext,int\u003e'),\n set_value ARRAY\u003cSTRING(MAX)\u003e OPTIONS (cassandra_type = 'set\u003cuuid\u003e'),\n date_value DATE OPTIONS (cassandra_type = 'date'),\n time_value INT64 OPTIONS (cassandra_type = 'time'),\n) PRIMARY KEY (id);\n\nCREATE TABLE IF NOT EXISTS sensor_data (\n sensor_id STRING(MAX) NOT NULL OPTIONS (cassandra_type = 'uuid'),\n reading_time TIMESTAMP NOT NULL OPTIONS (cassandra_type = 'timestamp'),\n location STRING(MAX) NOT NULL OPTIONS (cassandra_type = 'text'),\n temperature NUMERIC OPTIONS (cassandra_type = 'decimal'),\n humidity NUMERIC OPTIONS (cassandra_type = 'decimal'),\n pressure NUMERIC OPTIONS (cassandra_type = 'decimal'),\n) PRIMARY KEY (sensor_id, location, reading_time);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudspannerecosystem%2Fspanner-cassandra-schema-tool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloudspannerecosystem%2Fspanner-cassandra-schema-tool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudspannerecosystem%2Fspanner-cassandra-schema-tool/lists"}