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

ch10 - sparksql- Inserting into tables query not working Cannot safely cast 'count': string to bigint #68

Open
shanmugavel04 opened this issue Jun 20, 2021 · 0 comments

Comments

@shanmugavel04
Copy link

Query in the book:
INSERT INTO partitioned_flights
PARTITION (DEST_COUNTRY_NAME="UNITED STATES")
SELECT count, ORIGIN_COUNTRY_NAME FROM flights
WHERE DEST_COUNTRY_NAME='UNITED STATES'
LIMIT 12
In Spark 3.0, The above query returns the below error in SQL statement: AnalysisException: Cannot write incompatible data to table 'default.partitioned_flights':

  • Cannot safely cast 'count': string to bigint
    so, modified the query as below to cast the count column as an integer.
    INSERT INTO partitioned_flights
    PARTITION (DEST_COUNTRY_NAME = "UNITED STATES")
    SELECT ORIGIN_COUNTRY_NAME, cast(count as int) count1 FROM flights
    WHERE DEST_COUNTRY_NAME = "UNITED STATES"
    LIMIT 12
    could you please check on this?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant