unytics/bigfunctions

[new]: `drop_dataset(dataset)`

unytics opened this issue · 1 comments

Check the idea has not already been suggested

Edit the title above with self-explanatory function name and argument names

  • The function name and the argument names I entered in the title above seems self explanatory to me.

BigFunction Description as it would appear in the documentation

get inspired from


    execute immediate 'create or replace temp table tables as (select table_name as name from `' || dataset || '`.INFORMATION_SCHEMA.TABLES where table_type != "VIEW")';
    execute immediate 'create or replace temp table views as (select table_name as name from `' || dataset || '`.INFORMATION_SCHEMA.TABLES where table_type = "VIEW")';
    execute immediate 'create or replace temp table routines as (select routine_name, routine_type from `' || dataset || '`.INFORMATION_SCHEMA.ROUTINES)';

    for record in (select * from tables) do
        execute immediate 'drop table `' || dataset || '.' || record.name || '`';
    end for;

    for record in (select * from views) do
        execute immediate 'drop view `' || dataset || '.' || record.name || '`';
    end for;

    for record in (select * from routines) do
        execute immediate 'drop ' || record.routine_type || ' `' || dataset || '.' || record.routine_name || '`';
    end for;

execute immediate "drop schema " || dataset;

Examples of (arguments, expected output) as they would appear in the documentation

  • my_dataset

Add bq ML model to delete.