Example #1
0
        def drop_table(db_table):
            drop_table_hql = HQLGenerator.generate_drop_table(
                db_table).with_semicolon()

            try:
                logging.info("Dropping table {} from Hive".format(db_table))
                self.emr_system.execute_hive(drop_table_hql)
                return 1
            except Exception:
                logging.warning("Unable to drop {} table".format(db_table))
                return 0
Example #2
0
        def reset_table(db_table, create_table_hql, table_location,
                        table_partitioned_flag):
            if table_partitioned_flag:
                drop_table_hql = HQLGenerator.generate_drop_table(
                    db_table).with_semicolon()
                repair_table_hql = HQLGenerator.generate_repair_table(
                    db_table).with_semicolon()
                hql = "\n".join(
                    [drop_table_hql, create_table_hql, repair_table_hql])
            else:
                hql = HQLGenerator.generate_alter_table_location(
                    db_table, table_location).with_semicolon()

            try:
                logging.info("Resetting '{}' table.".format(db_table))
                self.emr_system.execute_hive(hql)
            except M3DEMRStepException as e:
                if "Table not found" in str(e):
                    pass  # the table might already not be present, so we will ignore error arising from that case
                else:
                    logging.info("Failed to reset '{}' table: {}".format(
                        db_table, e))
                    raise