Skip to content

Instantly share code, notes, and snippets.

View prasku5's full-sized avatar
๐Ÿ˜€
Hello there!!

prasanna kumar prasku5

๐Ÿ˜€
Hello there!!
View GitHub Profile
@prasku5
prasku5 / grokking_to_leetcode.md
Created December 25, 2023 17:51 — forked from tykurtz/grokking_to_leetcode.md
Grokking the coding interview equivalent leetcode problems

GROKKING NOTES

I liked the way Grokking the coding interview organized problems into learnable patterns. However, the course is expensive and the majority of the time the problems are copy-pasted from leetcode. As the explanations on leetcode are usually just as good, the course really boils down to being a glorified curated list of leetcode problems.

So below I made a list of leetcode problems that are as close to grokking problems as possible.

Pattern: Sliding Window

sqoop export --connect jdbc:mysql://localhost/retail_export --username root
--export-dir /user/hive/warehouse/test_hive_import.db/order_items // Source
--table order_items_export // Destination table.
--update-mode allowinsert //when the source HDFS data has any changes it will over write in destination table
--update-key 'order_item_id,order_id' ---> comma seperated.
-m 1
--input-fields-terminated-by '\001'
--input-null-non-string "null"
--input-null-string "null"
--columns order_item_id ,order_item_order_id, order_item_product_id , order_item_quantity , order_item_subtotal ,order_item_product_price
sqoop merge \
--class-name products_replica \
--jar-file /tmp/sqoop-training/compile/58eef185483e6f0c39751a4fa136561d/products_replica.jar \
--new-data /user/training/problem5/products-text-part2 \
--onto /user/training/problem5/products-text-part1 \
--target-dir /user/training/problem5/products-text-both-parts \
--merge-key product_id
sqoop import --connect jdbc:mysql://localhost/retail_db \
--username root \
--target-dir /user/training/ \
--table orders \
--autoreset-to-one-mapper \
--delete-target-dir \
--create-hcatalog-table \
--hcatalog-database default \
--hcatalog-table my_table_orc \
--hcatalog-storage-stanza "stored as orcfile"
spark-shell
--master yarn \
--conf spark.ui.port = 15555 \
--executor-memory 2g \
--num-executors 2
sqoop import \
--connect jdbc:mysql://localhost/source_database_name \ (This is the path to access the Source DB using JDBC Driver)
--username <username> \ (Source Database Username)
--password <password> \ (Source Database password)
--database source_database_name \ (The database name will become folder name in target HDFS )
--target-dir <path of the directory> \
--hive-import \
--hive-table query_import \
--boundary-query 'SELECT 0, MAX(id) FROM a' \ (The boundary query allows sqoop to know the range of records that need to participate in import process)
--query 'SELECT a.id, a.name, b.id, b.name FROM a, b WHERE a.id = b.id AND $CONDITIONS'\
sqoop import-all-tables \
--connect jdbc:mysql://localhost/source_database_name \ (This is the path to access the Source DB using JDBC Driver)
--username <username> \ (Source Database Username)
--password <password> \ (Source Database password)
--database source_database_name \ (The database name will become folder name in target HDFS )
--exclude-tables <table1>,<table2> (we can exclude tables of our choice with this tag)
sqoop list-databases \
--connect jdbc:mysql://localhost/ \ (This is the path to access the Source DB using JDBC Driver)
--username <username> \ (Source Database Username)
--password <password> \ (Source Database password)
sqoop list-all-tables \
--connect jdbc:mysql://localhost/source_database_name \ (This is the path to access the Source DB using JDBC Driver)
--username <username> \ (Source Database Username)
--password <password> \ (Source Database password)
--database source_database_name \ (The database name will become folder name in target HDFS )
sqoop eval \
--connect jdbc:mysql://localhost/source_database_name \ (This is the path to access the Source DB using JDBC Driver)
--username <username> \ (Source Database Username)
--password <password> \ (Source Database password)
--database source_database_name \ (The database name will become folder name in target HDFS )
--query "SELECT * FROM <table_name> LIMIT 10"