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

bug: Mapped datetime values are typed as strings in the schema message #1695

Closed
1 task
edgarrmondragon opened this issue May 11, 2023 · 2 comments · Fixed by #2665
Closed
1 task

bug: Mapped datetime values are typed as strings in the schema message #1695

edgarrmondragon opened this issue May 11, 2023 · 2 comments · Fixed by #2665
Assignees
Labels

Comments

@edgarrmondragon
Copy link
Collaborator

Singer SDK Version

0.26.0

Is this a regression?

  • Yes

Python Version

NA

Bug scope

Mapping (stream maps, flattening, etc.)

Operating System

NA

Description

When generating a datetime value from a string using stream map functionality, e.g.

stream_maps:
  my_stream:
    created: datetime.datetime.from_timestamp(createdAt)

the detected schema type for the value falls back to string.

sdk/singer_sdk/mapper.py

Lines 372 to 379 in 33d64c8

if expr.startswith("float("):
return NumberType()
if expr.startswith("int("):
return IntegerType()
if expr.startswith("str("):
return StringType()

Code

No response

@edgarrmondragon edgarrmondragon changed the title bug: Mapped datetime values don't are typed as strings in the schema message bug: Mapped datetime values aren't typed as strings in the schema message May 7, 2024
@edgarrmondragon edgarrmondragon added the good first issue Good for newcomers label Jul 31, 2024
@edgarrmondragon edgarrmondragon self-assigned this Jul 31, 2024
@edgarrmondragon edgarrmondragon changed the title bug: Mapped datetime values aren't typed as strings in the schema message bug: Mapped datetime values are typed as strings in the schema message Sep 3, 2024
@dluo-sig
Copy link

dluo-sig commented Sep 6, 2024

Another similar issue in CustomStreamMap:

                existing_schema: dict = (
                    # Use transformed schema if available
                    transformed_schema["properties"].get(prop_key, {})
                    # ...or original schema for passthrough
                    or self.raw_schema["properties"].get(prop_def, {})
                )

If the stream map is defined using _['columnName'] or record['columnName'], the type mapping falls back to string because it doesn't look at the underlying column name, but rather treats the entire expression as the column that it's searching for. prop_def should check for that specification and pass through the appropriate column name.

@edgarrmondragon
Copy link
Collaborator Author

@dluo-sig Can you open a new issue for this? It is related, but I think it is a distinct 🐛.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants