Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 03:16 PM
Hi @amelia1 how are you?
What you got was indeed the top 5 rows (see that it was the Row class). What does it show when you run display(df)?
I'm thinking it might be something related to your schema, since you did not defined that, it can read the data in an unstructured matter, replacing some of the fields.
Can you please try defining it and passing on the spar.read?
from pyspark.sql import SparkSession
from pyspark.sql.types import StructType, StructField, StringType
# Create a SparkSession
spark = SparkSession.builder.appName("Example").getOrCreate()
# Define the schema
schema = StructType([
StructField("video_name", StringType(), True),
StructField("video_transcript", StringType(), True)
df = spark.read \
.format("jdbc") \
.schema(schema) \
.option("url", jdbc_url) \
.option("dbtable", dbtable) \
.load()
display(df)
Let me know if that solves your problem.
Best,
Alessandro