Created
March 27, 2025 21:15
-
-
Save amotl/17e8c03701a8e1803d6dff2429098e74 to your computer and use it in GitHub Desktop.
Limit of total columns [1000] in table [doc.total1000] exceeded
This file contains hidden or 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
#!/usr/bin/env python3 | |
# /// script | |
# requires-python = ">=3.9" | |
# dependencies = [ | |
# "sqlalchemy-cratedb", | |
# ] | |
# /// | |
""" | |
Usage: | |
uv run bug1000.py | |
""" | |
""" | |
As of Tue, 25 Mar 2025 03:19:33 GMT, that's version[6.0.0-SNAPSHOT], build[03f728c/NA], | |
an integration test [1] started failing. | |
The symptom is that when using `OBJECT(DYNAMIC)` and inserting arrays including objects, | |
each small, but totalling into more than 1000 fields, the venerable column limit error | |
is raised. | |
Limit of total columns [1000] in table [doc.total1000] exceeded | |
[1] https://github.com/crate/cratedb-toolkit/actions/runs/14050881248/job/39340940583 | |
""" | |
import sqlalchemy as sa | |
def main(): | |
engine = sa.create_engine("crate://crate@localhost:4200/") | |
table = "total1000" | |
drop = f"DROP TABLE IF EXISTS {table}" | |
ddl = f""" | |
CREATE TABLE IF NOT EXISTS {table} ( | |
"data" OBJECT(DYNAMIC) | |
) | |
""" | |
item = { | |
"time": 1743107159471, | |
"stmt": "SELECT * FROM sys.jobs_log WHERE stmt NOT LIKE '% -- ctk' OFFSET 591 -- ctk", | |
"duration": 4, | |
"username": "crate" | |
} | |
array = [item] * 250 | |
data = {"thing": array} | |
with engine.connect() as connection: | |
connection.execute(sa.text(drop)) | |
connection.execute(sa.text(ddl)) | |
connection.execute( | |
sa.text(f"INSERT INTO {table} (data) VALUES (:data)"), # noqa: S608 | |
{"data": data}, | |
) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment