SQL To Pyspark Conversion
SQL To Pyspark Conversion
https://www.linkedin.com/in/girish-gowda-8a58601b9/
Concept SQL PySpark
CURDATE,
from pyspark.sql.functions import current_date;
NOW, SELECT CURDATE() FROM table
df.select(current_date())
CURTIME
https://www.linkedin.com/in/girish-gowda-8a58601b9/
DDL operations
https://www.linkedin.com/in/girish-gowda-8a58601b9/
Concept SQL PySpark
https://www.linkedin.com/in/girish-gowda-8a58601b9
Modifying a
ALTER TABLE table_name df=df.withColumn("column_name",
column
MODIFY column_name datatype; df["column_name"].cast("datatype"))
Dropping a
ALTER TABLE table_name
column df = df.drop("column_name")
DROP COLUMN column_name;
ALTER TABLE table_name RENAME
COLUMN old_column_name TO
new_column_name;
Rename a
column In mysql,
ALTER TABLE employees CHANGE
COLUMN first_name
first_name_new VARCHAR(255);
df =df.withColumnRenamed("existing_column",
"new_column")
https://www.linkedin.com/in/girish-gowda-8a58601b9/