時間:2024-03-09 11:51作者:下載吧人氣:23
使用自定義參數方式實現 superset 實現SQL動態查詢
{{ current_username() }} 當前登錄用戶名
{{ current_username(add_to_cache_keys=False) }} 不從緩存中獲取登錄用戶名,默認從緩存獲取
{{ current_user_id()}} 當前登錄用戶ID
{{ current_user_id(add_to_cache_keys=False) }} 不從緩存中獲取登錄用戶ID,默認從緩存獲取
{{ url_param(‘custom_variable’) }} url 參數,比如127.0.0.1:8001dashboard?abc=123,參數就是{{ url_param(‘abc’) }} 結果就是123
{{ cache_key_wrapper() }} 還沒有弄明白啥用
{{ filter_values(“字段名”) }} 獲取dashboard filter_box組件對某個字段的篩選結果
{{ from_dttm }} 獲取dashboard filter_box組件日期篩選的開始時間
{{ to_dttm }} 獲取dashboard filter_box組件日期篩選的結束時間
{{ get_filters() }} 暫時沒有弄明白
除此之外,還可以自定義參數,自定義參數方法:
①修改superset/jinja_context.py文件,修改三個地方:
regex = re.compile(
r”{{.*(”
r”current_user_id(.*)|”
r”current_username(.*)|”
r”current_userroles(.*)|”
r”isadmin(.*)|”
r”cache_key_wrapper(.*)|”
r”url_param(.*)”
r”).*}}”
)
網友評論