Skip to content

Commit

Permalink
Truncate uuid length to 16
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik4949 committed Oct 25, 2024
1 parent 75741b6 commit e43d238
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Simple interactive shell
- Add pdf rag template
- Updated llm_finetuning template
- Add sql table length exceed limit and uuid truncation.

#### Bug Fixes

Expand Down
19 changes: 12 additions & 7 deletions plugins/ibis/superduper_ibis/db_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ class DBHelper:
"""

match_dialect = "base"
table_truncate = {'postgres': 63}
table_truncate_map = _KeyEqualDefaultDict()
truncates = {"postgres": {"column": 63, "table": 63}}

def __init__(self, dialect):
self.dialect = dialect
Expand All @@ -77,13 +76,19 @@ def process_before_insert(self, table_name, datas, conn):

columns = conn.table(table_name).columns
for column in datas.columns:
if conn.name in self.table_truncate:
n = self.table_truncate[conn.name]
if conn.name in self.truncates:
n = self.truncates[conn.name]["column"]
if len(column) > n:
self.table_truncate_map[column[:n]] = column

columns = list(map(lambda x: self.table_truncate_map[x], columns))
raise Exception(
f"{conn.name} database has limit of {n} for column name."
)
datas = datas[columns]
if conn.name in self.truncates:
if len(table_name) > self.truncates[conn.name]["table"]:
raise Exception(
f"{conn.name} database has limit of {n} for table name."
)

return table_name, pd.DataFrame(datas)

def process_schema_types(self, schema_mapping):
Expand Down
6 changes: 0 additions & 6 deletions plugins/ibis/superduper_ibis/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,6 @@ def _execute(self, parent, method="encode"):
) from e

assert isinstance(output, pandas.DataFrame)
table_truncate_map = self.db.databackend.db_helper.table_truncate_map
columns = {}
for c in output.columns:
columns[c] = table_truncate_map[c]
output = output.rename(columns=columns)

output = output.to_dict(orient="records")
component_table = self.db.load('table', self.table)
return SuperDuperCursor(
Expand Down
2 changes: 1 addition & 1 deletion superduper/base/leaf.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def __new__(mcs, name, bases, namespace):

def build_uuid():
"""Build UUID."""
return str(uuid.uuid4()).replace('-', '')
return str(uuid.uuid4()).replace('-', '')[:16]


class Leaf(metaclass=LeafMeta):
Expand Down

0 comments on commit e43d238

Please sign in to comment.