In [1]:
from marvin_python_toolbox.common.data_source_provider import get_spark_session
In [2]:
spark = get_spark_session(enable_hive=True)
In [3]:
dbs = spark.sql("show databases").collect()
In [4]:
for db in dbs:
db_name = db['databaseName']
print("Connecting with {} db ...".format(db_name))
spark.sql("use {}".format(db_name))
tables = spark.sql("show tables").collect()
for table in tables:
table_name = table['tableName']
count = spark.sql("select 1 from {}".format(table_name)).count()
print " {} [{}]".format(table_name, count)
In [ ]:
spark.stop()
In [6]:
spark.sql("select * from core.bsc_product").count()
Out[6]:
In [ ]: