Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: '_SpecialForm' object has no attribute 'avro_schema_to_python' #88

Closed
aeldaly-tc opened this issue Dec 3, 2020 · 6 comments
Labels
enhancement New feature or request

Comments

@aeldaly-tc
Copy link

Given a class such as this:

@dataclass
class BaseSchema(AvroModel):
    message_metadata: Dict[str, Any]

To Reproduce
calling
schema = BaseSchema.avro_schema()
produces the error
AttributeError: '_SpecialForm' object has no attribute 'avro_schema_to_python'

Expected behavior
It should return the schema

@marcosschroh
Copy link
Owner

Thanks @aeldaly-tc. Any is not a valid type in avro, you must use a proper type as the documentation describe. Anyway, we should show a more user friendly message for this case.

@leoscalco
Copy link

Just a contribution, fields with datetime.timestamp type also throws the following exception:

AttributeError: 'method_descriptor' object has no attribute 'avro_schema_to_python'

@marcosschroh
Copy link
Owner

Hi @leoscalco,

Do you mean that is not working for datetimes that are represented as timestamp? If that is the case, we do not have support for that. The logical types supported are: https://marcosschroh.github.io/dataclasses-avroschema/logical_types/

Maybe we can do something about it.

@marcosschroh marcosschroh added the enhancement New feature or request label Feb 12, 2021
@leoscalco
Copy link

I realized this after commenting here.

I was using long type for timestamps, but I found in your document the right way to work with dates.

Now, any sink connector is recognizing my date. Anyway thank you for support.

@marcosschroh
Copy link
Owner

Hi,

Perfect. I was thinking to add a new type to handle this option but maybe it not worth it at all. the user can make datetime.fromtimestamp(a_timestamp) and use the datetime.datetime type

@marcosschroh
Copy link
Owner

closed by #94

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants