Skip to content

Instantly share code, notes, and snippets.

@1ambda
Created December 24, 2021 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1ambda/5791494ecfb57cb7ea3a0c4d34535aa1 to your computer and use it in GitHub Desktop.
Save 1ambda/5791494ecfb57cb7ea3a0c4d34535aa1 to your computer and use it in GitHub Desktop.
queryListingJdbc = """(SELECT * FROM pipeline.ListingMeta WHERE listing_id >= 100000) AS target"""
dfListingJdbcFiltered = spark\
.read\
.format("jdbc")\
.option("driver", "com.mysql.jdbc.Driver")\
.option("url", "jdbc:mysql://localhost:3306?useSSL=false")\
.option("dbtable", queryListingJdbc)\
.option("user", "root")\
.option("password", "root")\
.option("partitionColumn", "listing_id")\
.option("lowerBound", "0")\
.option("upperBound", "1000")\
.option("customSchema", "listing_id LONG")\
.option("numPartitions", "5")\
.load()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment