BuzzCutNorman
08/08/2022, 5:18 PMValueError: Unable to merge sql types: INTEGER, INTEGER
during a meltano run
. The error is coming from File "C:\development\sdk\singer_sdk\streams\sql.py", line 744, in merge_sql_types
. I was wondering if merge_sql_types
should be working with integer
types or does it only work with string
and unicode
types at the moment?aaronsteers
08/08/2022, 5:24 PMvisch
08/08/2022, 5:25 PMvisch
08/08/2022, 5:25 PMaaronsteers
08/08/2022, 5:27 PMvisch
08/08/2022, 5:27 PMif str(sql_types[0]) == str(sql_types[1]):
return sql_types[0]
Whole function looks like this right now
def merge_sql_types(
self, sql_types: List[sqlalchemy.types.TypeEngine]
) -> sqlalchemy.types.TypeEngine:
"""Return a compatible SQL type for the selected type list.
Args:
sql_types: List of SQL types.
Returns:
A SQL type that is compatible with the input types.
Raises:
ValueError: If sql_types argument has zero members.
"""
if not sql_types:
raise ValueError("Expected at least one member in `sql_types` argument.")
if len(sql_types) == 1:
return sql_types[0]
sql_types = self._sort_types(sql_types)
if len(sql_types) > 2:
return self.merge_sql_types(
[self.merge_sql_types([sql_types[0], sql_types[1]])] + sql_types[2:]
)
assert len(sql_types) == 2
# SQL Alchemy overrides column type comparisons (only difference
# between super is these 2 lines)
if str(sql_types[0]) == str(sql_types[1]):
return sql_types[0]
generic_type = type(sql_types[0].as_generic())
if isinstance(generic_type, type):
if issubclass(
generic_type,
(sqlalchemy.types.String, sqlalchemy.types.Unicode),
):
return sql_types[0]
elif isinstance(
generic_type,
(sqlalchemy.types.String, sqlalchemy.types.Unicode),
):
return sql_types[0]
raise ValueError(
f"Unable to merge sql types: {', '.join([str(t) for t in sql_types])}"
)
still working through some other stuff so I haven't pushed thisBuzzCutNorman
08/08/2022, 5:34 PMif isisntance
and elif instance
almost seemed like they should have been combined.
if isinstance(generic_type, type):
if issubclass(
generic_type,
(sqlalchemy.types.String, sqlalchemy.types.Unicode),
):
return sql_types[0]
elif isinstance(
generic_type,
(sqlalchemy.types.String, sqlalchemy.types.Unicode),
):
return sql_types[0]
visch
08/08/2022, 5:37 PMif issubclass(
I think the idea is to check if the type is compatible with the other type using subclasses.thomas_briggs
08/08/2022, 5:42 PMthomas_briggs
08/08/2022, 5:45 PMvisch
08/08/2022, 5:50 PMif isinstance(generic_type, type):
if issubclass(
generic_type,
(sqlalchemy.types.String, sqlalchemy.types.Unicode),
):
return sql_types[0]
check doesn't' work? It's because it's only checking Strings/Unicode types! There wasn't a check added for non Stringsvisch
08/08/2022, 5:51 PMthomas_briggs
08/08/2022, 5:52 PMBuzzCutNorman
08/08/2022, 6:06 PMgeneric, string, and unicode
. I think the way the if statements are setup are not allowing the recursion for generic
types to complete. The assert
alerts us to the final conflict. The if statement you and Thomas added allows you to get past the error by not allowing the final check against sqltype[0]
and sqltype[1]
if they are equal.aaronsteers
08/08/2022, 6:11 PMedgar_ramirez_mondragon
09/10/2022, 1:01 AM