Spaces:
Sleeping
Sleeping
File size: 2,662 Bytes
6c263e6 1f6109d 1126831 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | import gradio as gr
from json_2_incr_ddl import get_ddl_results
from hive_copyfields_extract import get_extract_fields
def point_2_ddl(topic_name, biz_name, json_example):
return get_ddl_results(topic_name, biz_name, json_example)
def hive_copy_fields_2_str(hive_copy_str):
return get_extract_fields(hive_copy_str)
with gr.Blocks() as demo:
json_str = '''
{
"Email": "835610010@qq.com",
"UseType": 946,
"Lang": 2,
"Sub": "22",
"HtmlBody": "22",
"HasBody": true
}
'''
hue_fields = '''
fid (bigint)
fuserid (bigint)
froomid (bigint)
ftype (int)
fcount (int)
frecordtime (timestamp)
fcreatetime (timestamp)
fmodifytime (timestamp)
'''
with gr.Tab("根据json生成ddl"):
with gr.Row():
with gr.Column():
json_input = [
gr.Text(label="topic名称", placeholder="Email_Send_Topic"),
gr.Text(label="业务线名称", placeholder="ludo"),
gr.Text(label="Json类埋点单条示例", lines=6, placeholder=json_str)
]
json_button = gr.Button("Click")
with gr.Column():
ddl_output = [
gr.Text(label="incr表", show_copy_button=True, text_align="left"),
gr.Text(label="incr_text表", show_copy_button=True, text_align="left"),
gr.Text(label="incr_explode表", show_copy_button=True, text_align="left"),
gr.Text(label="explode sql", show_copy_button=True, text_align="left"),
gr.Text(label="azkaban job", show_copy_button=True, text_align="left")
]
json_button.click(point_2_ddl, inputs=json_input, outputs=ddl_output)
with gr.Tab("根据hue复制字段生成特定字串"):
with gr.Row():
with gr.Column():
hue_input = gr.Text(label="从hue中复制的字段内容", placeholder=hue_fields, lines=10)
hue_button = gr.Button("Click")
with gr.Column():
fields_output = [
gr.Text(label="不带“,”的字段", show_copy_button=True, text_align="left"),
gr.Text(label="带“,”的字段", show_copy_button=True, text_align="left"),
gr.Text(label="没有换行符的字段", show_copy_button=True, text_align="left"),
gr.Text(label="特殊字段", show_copy_button=True, text_align="left")
]
hue_button.click(hive_copy_fields_2_str, inputs=hue_input, outputs=fields_output)
demo.launch(debug=True)
|