本文整理汇总了Python中beeswax.models.SavedQuery.create_empty方法的典型用法代码示例。如果您正苦于以下问题:Python SavedQuery.create_empty方法的具体用法?Python SavedQuery.create_empty怎么用?Python SavedQuery.create_empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类beeswax.models.SavedQuery
的用法示例。
在下文中一共展示了SavedQuery.create_empty方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: drop_table
# 需要导入模块: from beeswax.models import SavedQuery [as 别名]
# 或者: from beeswax.models.SavedQuery import create_empty [as 别名]
def drop_table(request, database):
db = dbms.get(request.user)
if request.method == 'POST':
try:
tables = request.POST.getlist('table_selection')
tables_objects = [db.get_table(database, table) for table in tables]
skip_trash = request.POST.get('skip_trash') == 'on'
if request.POST.get('is_embeddable'):
sql = db.drop_tables(database, tables_objects, design=None, skip_trash=skip_trash, generate_ddl_only=True)
job = make_notebook(
name='Execute and watch',
editor_type='hive',
statement=sql.strip(),
status='ready',
database=database,
on_success_url='assist.db.refresh',
is_task=True
)
return JsonResponse(job.execute(request))
else:
# Can't be simpler without an important refactoring
design = SavedQuery.create_empty(app_name='beeswax', owner=request.user, data=hql_query('').dumps())
query_history = db.drop_tables(database, tables_objects, design, skip_trash=skip_trash)
url = reverse('beeswax:watch_query_history', kwargs={'query_history_id': query_history.id}) + '?on_success_url=' + reverse('metastore:show_tables', kwargs={'database': database})
return redirect(url)
except Exception, ex:
error_message, log = dbms.expand_exception(ex, db)
error = _("Failed to remove %(tables)s. Error: %(error)s") % {'tables': ','.join(tables), 'error': error_message}
raise PopupException(error, title=_("Hive Error"), detail=log)
示例2: drop_database
# 需要导入模块: from beeswax.models import SavedQuery [as 别名]
# 或者: from beeswax.models.SavedQuery import create_empty [as 别名]
def drop_database(request):
db = dbms.get(request.user)
if request.method == 'POST':
databases = request.POST.getlist('database_selection')
try:
design = SavedQuery.create_empty(app_name='beeswax', owner=request.user, data=hql_query('').dumps())
if request.POST.get('is_embeddable'):
sql = db.drop_databases(databases, design, generate_ddl_only=True)
job = make_notebook(
name='Execute and watch',
editor_type='hive',
statement=sql.strip(),
status='ready',
database=None,
on_success_url='assist.db.refresh',
is_task=True
)
return JsonResponse(job.execute(request))
else:
query_history = db.drop_databases(databases, design)
url = reverse('beeswax:watch_query_history', kwargs={'query_history_id': query_history.id}) + '?on_success_url=' + reverse('metastore:databases')
return redirect(url)
except Exception, ex:
error_message, log = dbms.expand_exception(ex, db)
error = _("Failed to remove %(databases)s. Error: %(error)s") % {'databases': ','.join(databases), 'error': error_message}
raise PopupException(error, title=_("Hive Error"), detail=log)
示例3: drop_partition
# 需要导入模块: from beeswax.models import SavedQuery [as 别名]
# 或者: from beeswax.models.SavedQuery import create_empty [as 别名]
def drop_partition(request, database, table):
source_type = request.POST.get('source_type', 'hive')
cluster = json.loads(request.POST.get('cluster', '{}'))
db = _get_db(user=request.user, source_type=source_type, cluster=cluster)
if request.method == 'POST':
partition_specs = request.POST.getlist('partition_selection')
partition_specs = [spec for spec in partition_specs]
try:
if request.GET.get("format", "html") == "json":
last_executed = json.loads(request.POST.get('start_time'), '-1')
sql = db.drop_partitions(database, table, partition_specs, design=None, generate_ddl_only=True)
job = make_notebook(
name=_('Drop partition %s') % ', '.join(partition_specs)[:100],
editor_type=source_type,
statement=sql.strip(),
status='ready',
database=None,
on_success_url='assist.db.refresh',
is_task=True,
last_executed=last_executed
)
return JsonResponse(job.execute(request))
else:
design = SavedQuery.create_empty(app_name='beeswax', owner=request.user, data=hql_query('').dumps())
query_history = db.drop_partitions(database, table, partition_specs, design)
url = reverse('beeswax:watch_query_history', kwargs={'query_history_id': query_history.id}) + '?on_success_url=' + \
reverse('metastore:describe_partitions', kwargs={'database': database, 'table': table})
return redirect(url)
except Exception, ex:
error_message, log = dbms.expand_exception(ex, db)
error = _("Failed to remove %(partition)s. Error: %(error)s") % {'partition': '\n'.join(partition_specs), 'error': error_message}
raise PopupException(error, title=_("DB Error"), detail=log)
示例4: drop_database
# 需要导入模块: from beeswax.models import SavedQuery [as 别名]
# 或者: from beeswax.models.SavedQuery import create_empty [as 别名]
def drop_database(request):
source_type = request.POST.get('source_type', request.GET.get('source_type', 'hive'))
cluster = json.loads(request.POST.get('cluster', '{}'))
db = _get_db(user=request.user, source_type=source_type, cluster=cluster)
if request.method == 'POST':
databases = request.POST.getlist('database_selection')
try:
if request.POST.get('is_embeddable'):
design = SavedQuery.create_empty(app_name=source_type if source_type != 'hive' else 'beeswax', owner=request.user, data=hql_query('').dumps())
last_executed = json.loads(request.POST.get('start_time'), '-1')
cluster = json.loads(request.POST.get('cluster', '{}'))
namespace = request.POST.get('namespace')
sql = db.drop_databases(databases, design, generate_ddl_only=True)
job = make_notebook(
name=_('Drop database %s') % ', '.join(databases)[:100],
editor_type=source_type,
statement=sql.strip(),
status='ready',
database=None,
namespace=namespace,
compute=cluster,
on_success_url='assist.db.refresh',
is_task=True,
last_executed=last_executed
)
return JsonResponse(job.execute(request))
else:
design = SavedQuery.create_empty(app_name='beeswax', owner=request.user, data=hql_query('').dumps())
query_history = db.drop_databases(databases, design)
url = reverse('beeswax:watch_query_history', kwargs={'query_history_id': query_history.id}) + '?on_success_url=' + reverse('metastore:databases')
return redirect(url)
except Exception, ex:
error_message, log = dbms.expand_exception(ex, db)
error = _("Failed to remove %(databases)s. Error: %(error)s") % {'databases': ','.join(databases), 'error': error_message}
raise PopupException(error, title=_("DB Error"), detail=log)
示例5: load_table
# 需要导入模块: from beeswax.models import SavedQuery [as 别名]
# 或者: from beeswax.models.SavedQuery import create_empty [as 别名]
def load_table(request, database, table):
response = {'status': -1, 'data': 'None'}
source_type = request.POST.get('source_type', request.GET.get('source_type', 'hive'))
cluster = json.loads(request.POST.get('cluster', '{}'))
db = _get_db(user=request.user, source_type=source_type, cluster=cluster)
table = db.get_table(database, table)
if request.method == "POST":
load_form = LoadDataForm(table, request.POST)
if load_form.is_valid():
on_success_url = reverse('metastore:describe_table', kwargs={'database': database, 'table': table.name})
generate_ddl_only = request.POST.get('is_embeddable', 'false') == 'true'
try:
design = SavedQuery.create_empty(app_name=source_type if source_type != 'hive' else 'beeswax', owner=request.user, data=hql_query('').dumps())
form_data = {
'path': load_form.cleaned_data['path'],
'overwrite': load_form.cleaned_data['overwrite'],
'partition_columns': [(column_name, load_form.cleaned_data[key]) for key, column_name in load_form.partition_columns.iteritems()],
}
query_history = db.load_data(database, table.name, form_data, design, generate_ddl_only=generate_ddl_only)
if generate_ddl_only:
last_executed = json.loads(request.POST.get('start_time'), '-1')
job = make_notebook(
name=_('Load data in %s.%s') % (database, table.name),
editor_type=source_type,
statement=query_history.strip(),
status='ready',
database=database,
on_success_url='assist.db.refresh',
is_task=True,
last_executed=last_executed
)
response = job.execute(request)
else:
url = reverse('beeswax:watch_query_history', kwargs={'query_history_id': query_history.id}) + '?on_success_url=' + on_success_url
response['status'] = 0
response['data'] = url
response['query_history_id'] = query_history.id
except QueryError, ex:
response['status'] = 1
response['data'] = _("Can't load the data: ") + ex.message
except Exception, e:
response['status'] = 1
response['data'] = _("Can't load the data: ") + str(e)
示例6: drop_database
# 需要导入模块: from beeswax.models import SavedQuery [as 别名]
# 或者: from beeswax.models.SavedQuery import create_empty [as 别名]
def drop_database(request):
db = dbms.get(request.user)
if request.method == 'POST':
databases = request.POST.getlist('database_selection')
try:
# Can't be simpler without an important refactoring
design = SavedQuery.create_empty(app_name='beeswax', owner=request.user, data=hql_query('').dumps())
query_history = db.drop_databases(databases, design)
url = reverse('beeswax:watch_query_history', kwargs={'query_history_id': query_history.id}) + '?on_success_url=' + reverse('metastore:databases')
return redirect(url)
except Exception, ex:
error_message, log = dbms.expand_exception(ex, db)
error = _("Failed to remove %(databases)s. Error: %(error)s") % {'databases': ','.join(databases), 'error': error_message}
raise PopupException(error, title=_("Hive Error"), detail=log)
示例7: drop_partition
# 需要导入模块: from beeswax.models import SavedQuery [as 别名]
# 或者: from beeswax.models.SavedQuery import create_empty [as 别名]
def drop_partition(request, database, table):
db = dbms.get(request.user)
if request.method == 'POST':
partition_specs = request.POST.getlist('partition_selection')
partition_specs = [spec for spec in partition_specs]
try:
design = SavedQuery.create_empty(app_name='beeswax', owner=request.user, data=hql_query('').dumps())
query_history = db.drop_partitions(database, table, partition_specs, design)
url = reverse('beeswax:watch_query_history', kwargs={'query_history_id': query_history.id}) + '?on_success_url=' + \
reverse('metastore:describe_partitions', kwargs={'database': database, 'table': table})
return redirect(url)
except Exception, ex:
error_message, log = dbms.expand_exception(ex, db)
error = _("Failed to remove %(partition)s. Error: %(error)s") % {'partition': '\n'.join(partition_specs), 'error': error_message}
raise PopupException(error, title=_("Hive Error"), detail=log)
示例8: drop_table
# 需要导入模块: from beeswax.models import SavedQuery [as 别名]
# 或者: from beeswax.models.SavedQuery import create_empty [as 别名]
def drop_table(request, database):
db = dbms.get(request.user)
if request.method == 'POST':
tables = request.POST.getlist('table_selection')
tables_objects = [db.get_table(database, table) for table in tables]
try:
# Can't be simpler without an important refactoring
design = SavedQuery.create_empty(app_name='beeswax', owner=request.user)
query_history = db.drop_tables(database, tables_objects, design)
url = reverse('beeswax:watch_query', args=[query_history.id]) + '?on_success_url=' + reverse('catalog:show_tables')
return redirect(url)
except Exception, ex:
error_message, log = dbms.expand_exception(ex, db)
error = _("Failed to remove %(tables)s. Error: %(error)s") % {'tables': ','.join(tables), 'error': error_message}
raise PopupException(error, title=_("Beeswax Error"), detail=log)
示例9: load_table
# 需要导入模块: from beeswax.models import SavedQuery [as 别名]
# 或者: from beeswax.models.SavedQuery import create_empty [as 别名]
def load_table(request, database, table):
db = dbms.get(request.user)
table = db.get_table(database, table)
response = {'status': -1, 'data': 'None'}
if request.method == "POST":
load_form = LoadDataForm(table, request.POST)
if load_form.is_valid():
on_success_url = reverse('metastore:describe_table', kwargs={'database': database, 'table': table.name})
try:
design = SavedQuery.create_empty(app_name='beeswax', owner=request.user, data=hql_query('').dumps())
query_history = db.load_data(database, table, load_form, design)
url = reverse('beeswax:watch_query_history', kwargs={'query_history_id': query_history.id}) + '?on_success_url=' + on_success_url
response['status'] = 0
response['data'] = url
except Exception, e:
response['status'] = 1
response['data'] = _("Can't load the data: ") + str(e)
示例10: load_table
# 需要导入模块: from beeswax.models import SavedQuery [as 别名]
# 或者: from beeswax.models.SavedQuery import create_empty [as 别名]
def load_table(request, database, table):
db = dbms.get(request.user)
table = db.get_table(database, table)
response = {"status": -1, "data": "None"}
if request.method == "POST":
load_form = LoadDataForm(table, request.POST)
if load_form.is_valid():
on_success_url = reverse("metastore:describe_table", kwargs={"database": database, "table": table.name})
try:
design = SavedQuery.create_empty(app_name="beeswax", owner=request.user)
query_history = db.load_data(database, table, load_form, design)
url = reverse("beeswax:watch_query", args=[query_history.id]) + "?on_success_url=" + on_success_url
response["status"] = 0
response["data"] = url
except Exception, e:
response["status"] = 1
response["data"] = _("Can't load the data: ") + str(e)
示例11: drop_table
# 需要导入模块: from beeswax.models import SavedQuery [as 别名]
# 或者: from beeswax.models.SavedQuery import create_empty [as 别名]
def drop_table(request, database):
source_type = request.POST.get('source_type', request.GET.get('source_type', 'hive'))
cluster = json.loads(request.POST.get('cluster', '{}'))
db = _get_db(user=request.user, source_type=source_type, cluster=cluster)
if request.method == 'POST':
try:
tables = request.POST.getlist('table_selection')
tables_objects = [db.get_table(database, table) for table in tables]
skip_trash = request.POST.get('skip_trash') == 'on'
cluster = json.loads(request.POST.get('cluster', '{}'))
namespace = request.POST.get('namespace')
if request.POST.get('is_embeddable'):
last_executed = json.loads(request.POST.get('start_time'), '-1')
sql = db.drop_tables(database, tables_objects, design=None, skip_trash=skip_trash, generate_ddl_only=True)
job = make_notebook(
name=_('Drop table %s') % ', '.join([table.name for table in tables_objects])[:100],
editor_type=source_type,
statement=sql.strip(),
status='ready',
database=database,
namespace=namespace,
compute=cluster,
on_success_url='assist.db.refresh',
is_task=True,
last_executed=last_executed
)
return JsonResponse(job.execute(request))
else:
# Can't be simpler without an important refactoring
design = SavedQuery.create_empty(app_name='beeswax', owner=request.user, data=hql_query('').dumps())
query_history = db.drop_tables(database, tables_objects, design, skip_trash=skip_trash)
url = reverse('beeswax:watch_query_history', kwargs={'query_history_id': query_history.id}) + '?on_success_url=' + reverse('metastore:show_tables', kwargs={'database': database})
return redirect(url)
except Exception, ex:
error_message, log = dbms.expand_exception(ex, db)
error = _("Failed to remove %(tables)s. Error: %(error)s") % {'tables': ','.join(tables), 'error': error_message}
raise PopupException(error, title=_("DB Error"), detail=log)
示例12: drop_partition
# 需要导入模块: from beeswax.models import SavedQuery [as 别名]
# 或者: from beeswax.models.SavedQuery import create_empty [as 别名]
def drop_partition(request, database, table):
db = dbms.get(request.user)
if request.method == "POST":
partition_specs = request.POST.getlist("partition_selection")
partition_specs = [spec for spec in partition_specs]
try:
design = SavedQuery.create_empty(app_name="beeswax", owner=request.user, data=hql_query("").dumps())
query_history = db.drop_partitions(database, table, partition_specs, design)
url = (
reverse("beeswax:watch_query_history", kwargs={"query_history_id": query_history.id})
+ "?on_success_url="
+ reverse("metastore:describe_partitions", kwargs={"database": database, "table": table})
)
return redirect(url)
except Exception, ex:
error_message, log = dbms.expand_exception(ex, db)
error = _("Failed to remove %(partition)s. Error: %(error)s") % {
"partition": "\n".join(partition_specs),
"error": error_message,
}
raise PopupException(error, title=_("Hive Error"), detail=log)
示例13: drop_database
# 需要导入模块: from beeswax.models import SavedQuery [as 别名]
# 或者: from beeswax.models.SavedQuery import create_empty [as 别名]
def drop_database(request):
db = dbms.get(request.user)
if request.method == "POST":
databases = request.POST.getlist("database_selection")
try:
# Can't be simpler without an important refactoring
design = SavedQuery.create_empty(app_name="beeswax", owner=request.user, data=hql_query("").dumps())
query_history = db.drop_databases(databases, design)
url = (
reverse("beeswax:watch_query_history", kwargs={"query_history_id": query_history.id})
+ "?on_success_url="
+ reverse("metastore:databases")
)
return redirect(url)
except Exception, ex:
error_message, log = dbms.expand_exception(ex, db)
error = _("Failed to remove %(databases)s. Error: %(error)s") % {
"databases": ",".join(databases),
"error": error_message,
}
raise PopupException(error, title=_("Hive Error"), detail=log)
示例14: drop_table
# 需要导入模块: from beeswax.models import SavedQuery [as 别名]
# 或者: from beeswax.models.SavedQuery import create_empty [as 别名]
def drop_table(request, database):
db = dbms.get(request.user)
if request.method == "POST":
tables = request.POST.getlist("table_selection")
tables_objects = [db.get_table(database, table) for table in tables]
try:
# Can't be simpler without an important refactoring
design = SavedQuery.create_empty(app_name="beeswax", owner=request.user)
query_history = db.drop_tables(database, tables_objects, design)
url = (
reverse("beeswax:watch_query", args=[query_history.id])
+ "?on_success_url="
+ reverse("metastore:show_tables")
)
return redirect(url)
except Exception, ex:
error_message, log = dbms.expand_exception(ex, db)
error = _("Failed to remove %(tables)s. Error: %(error)s") % {
"tables": ",".join(tables),
"error": error_message,
}
raise PopupException(error, title=_("Beeswax Error"), detail=log)