Closed shiyuhang0 closed 2 years ago
PTAL @dbeatty
I meet a strange problem.
run PYTHONPATH=. pytest tests/functional/adapter/basic/mysql_test.py
and most of the test will fail with the following error. Note that all the tests are passed before, I don't known which step cause the error. (MySQL version 8.0.30)
cls = <class 'dbt.adapters.mysql.relation.MySQLRelation'>
d = {'path': {'database': None, 'identifier': 'base', 'schema': 'test16619424838555888224_mysql_test'}, 'type': "bytearray(b'table')"}
use_bytes = False, use_enum = False, use_datetime = False
> ???
<string>:21:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <enum 'RelationType'>, value = "bytearray(b'table')"
@classmethod
def _deserialize(cls, value: str):
> return cls(value)
/Users/shiyuhang/github/dbt-mysql/vene/lib/python3.9/site-packages/dbt/dataclass_schema.py:130:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <enum 'RelationType'>, value = "bytearray(b'table')", names = None
def __call__(cls, value, names=None, *, module=None, qualname=None, type=None, start=1):
"""
Either returns an existing member, or creates a new enum class.
This method is used both when an enum class is given a value to match
to an enumeration member (i.e. Color(3)) and for the functional API
(i.e. Color = Enum('Color', names='RED GREEN BLUE')).
When used for the functional API:
`value` will be the name of the new class.
`names` should be either a string of white-space/comma delimited names
(values will start at `start`), or an iterator/mapping of name, value pairs.
`module` should be set to the module this class is being created in;
if it is not set, an attempt to find that module will be made, but if
it fails the class will not be picklable.
`qualname` should be set to the actual location this class can be found
at in its module; by default it is set to the global scope. If this is
not correct, unpickling will fail in some circumstances.
`type`, if set, will be mixed in as the first base class.
"""
if names is None: # simple value lookup
> return cls.__new__(cls, value)
/opt/homebrew/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/enum.py:384:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <enum 'RelationType'>, value = "bytearray(b'table')"
def __new__(cls, value):
# all enum instances are actually created during class construction
# without calling this method; this method is called by the metaclass'
# __call__ (i.e. Color(3) ), and by pickle
if type(value) is cls:
# For lookups like Color(Color.RED)
return value
# by-value search for a matching enum member
# see if it's in the reverse mapping (for hashable values)
try:
return cls._value2member_map_[value]
except KeyError:
# Not found, no need to do long O(n) search
pass
except TypeError:
# not there, now do long search -- O(n) behavior
for member in cls._member_map_.values():
if member._value_ == value:
return member
# still not found -- try _missing_ hook
try:
exc = None
result = cls._missing_(value)
except Exception as e:
exc = e
result = None
try:
if isinstance(result, cls):
return result
else:
ve_exc = ValueError("%r is not a valid %s" % (value, cls.__qualname__))
if result is None and exc is None:
> raise ve_exc
E ValueError: "bytearray(b'table')" is not a valid RelationType
/opt/homebrew/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/enum.py:702: ValueError
During handling of the above exception, another exception occurred:
self = <mysql_test.TestGenericTestsMyAdapter object at 0x110898610>, project = <dbt.tests.fixtures.project.TestProjInfo object at 0x112ced2b0>
def test_generic_tests(self, project):
# seed command
results = run_dbt(["seed"])
# test command selecting base model
> results = run_dbt(["test", "-m", "base"])
/Users/shiyuhang/github/dbt-mysql/vene/lib/python3.9/site-packages/dbt/tests/adapter/basic/test_generic_tests.py:41:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/Users/shiyuhang/github/dbt-mysql/vene/lib/python3.9/site-packages/dbt/tests/util.py:65: in run_dbt
res, success = handle_and_check(args)
/Users/shiyuhang/github/dbt-mysql/vene/lib/python3.9/site-packages/dbt/main.py:191: in handle_and_check
task, res = run_from_args(parsed)
/Users/shiyuhang/github/dbt-mysql/vene/lib/python3.9/site-packages/dbt/main.py:238: in run_from_args
results = task.run()
/Users/shiyuhang/github/dbt-mysql/vene/lib/python3.9/site-packages/dbt/task/runnable.py:470: in run
result = self.execute_with_hooks(selected_uids)
/Users/shiyuhang/github/dbt-mysql/vene/lib/python3.9/site-packages/dbt/task/runnable.py:432: in execute_with_hooks
self.before_run(adapter, selected_uids)
/Users/shiyuhang/github/dbt-mysql/vene/lib/python3.9/site-packages/dbt/task/run.py:441: in before_run
self.populate_adapter_cache(adapter, required_schemas)
/Users/shiyuhang/github/dbt-mysql/vene/lib/python3.9/site-packages/dbt/task/runnable.py:407: in populate_adapter_cache
adapter.set_relations_cache(self.manifest)
/Users/shiyuhang/github/dbt-mysql/vene/lib/python3.9/site-packages/dbt/adapters/base/impl.py:385: in set_relations_cache
self._relations_cache_for_schemas(manifest, required_schemas)
/Users/shiyuhang/github/dbt-mysql/vene/lib/python3.9/site-packages/dbt/adapters/base/impl.py:365: in _relations_cache_for_schemas
for relation in future.result():
/opt/homebrew/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/_base.py:439: in result
return self.__get_result()
/opt/homebrew/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/_base.py:391: in __get_result
raise self._exception
/opt/homebrew/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/thread.py:58: in run
result = self.fn(*self.args, **self.kwargs)
/Users/shiyuhang/github/dbt-mysql/vene/lib/python3.9/site-packages/dbt/utils.py:473: in connected
return func(*args, **kwargs)
/Users/shiyuhang/github/dbt-mysql/dbt/adapters/mysql/impl.py:70: in list_relations_without_caching
relation = self.Relation.create(
/Users/shiyuhang/github/dbt-mysql/vene/lib/python3.9/site-packages/dbt/adapters/base/relation.py:282: in create
return cls.from_dict(kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'dbt.adapters.mysql.relation.MySQLRelation'>
d = {'path': {'database': None, 'identifier': 'base', 'schema': 'test16619424838555888224_mysql_test'}, 'type': "bytearray(b'table')"}
use_bytes = False, use_enum = False, use_datetime = False
> ???
E mashumaro.exceptions.InvalidFieldValue: Field "type" of type Optional[RelationType] in MySQLRelation has invalid value "bytearray(b'table')"
<string>:23: InvalidFieldValue
I missed this pr before. Thank you for merging it.
As for the problem I mentioned in the comment, I forget the details about it, but it succeed now in my local environment with this commit. Do you know why it failed before and succeeds now? Thanks
resolves #105
Description