Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return "PARTITION({})".format(", ".join(target_partitions))
else:
return ""
def make_insert_str():
return "INSERT INTO TABLE {}".format(target_table)
hql_statement = """
{insert_str} {partition_str}
{select_str}
""".format(
insert_str=make_insert_str(),
partition_str=make_partition_str(),
select_str=select_statement.no_semicolon()
)
return HQLGenerator.Statement(hql_statement)
lambda s: HQLGenerator.Statement.MULTIPLE_RETURN_REGEX.sub(HQLGenerator.Statement.RETURN_CHAR, s)
])
def generate_drop_table_if_exists(table_name):
hql_statement = 'DROP TABLE IF EXISTS {}'.format(table_name)
return HQLGenerator.Statement(hql_statement)
def make_distribute_by_str():
if len(self._distribute_columns) > 0:
return "DISTRIBUTE BY ({})".format(", ".join(self._distribute_columns))
else:
return ""
hql_statement = """
{select_str}
{from_str}
{distribute_str}
""".format(
select_str=make_select_str(),
from_str=make_from_str(),
distribute_str=make_distribute_by_str()
)
return HQLGenerator.Statement(hql_statement)
def generate_drop_view(view_name):
hql_statement = 'DROP VIEW {}'.format(view_name)
return HQLGenerator.Statement(hql_statement)
def generate_create_database_if_not_exits(database_name):
hql_statement = "CREATE DATABASE IF NOT EXISTS {}".format(database_name)
return HQLGenerator.Statement(hql_statement)
def generate_drop_table(table_name):
hql_statement = 'DROP TABLE {}'.format(table_name)
return HQLGenerator.Statement(hql_statement)
def generate_describe(entity):
hql_statement = "DESCRIBE {}".format(entity)
return HQLGenerator.Statement(hql_statement)
lambda s: HQLGenerator.Statement.MULTIPLE_SPACE_REGEX.sub(HQLGenerator.Statement.SPACE_CHAR, s),
lambda s: HQLGenerator.Statement.MULTIPLE_RETURN_REGEX.sub(HQLGenerator.Statement.RETURN_CHAR, s)
def generate_alter_table_location(table_name, table_location):
hql_statement = 'ALTER TABLE {} SET LOCATION "{}"'.format(table_name, table_location)
return HQLGenerator.Statement(hql_statement)