【代码报错】Permission Error: 请在查询表 cn_stock_bar1d 时使用 filters 参数指定分区范围(一般为 date 或 instrument )
由bq44a10w创建,最终由small_q 被浏览 8 用户
在输入特征中输入模式种选择“SQL”,SQL特征中写下相关代码(见下方代码块所示),运行整个代码块之后,得到如标题错误信息。该问题应该是一个基础问题,但就是不知道哪里出错了,目前因无法连接github,无法生成分享链接,请各位大神指教,谢谢!
错误信息如下:
- [2025-01-02 22:50:09] INFO: cn_stock_basic_selector.v8 开始运行 ..
- [2025-01-02 22:50:09] INFO: cn_stock_basic_selector.v8 命中缓存
- [2025-01-02 22:50:09] INFO: cn_stock_basic_selector.v8 运行完成 [0.183s].
- [2025-01-02 22:50:09] INFO: input_features_dai.v30 开始运行 ..
- [2025-01-02 22:50:09] INFO: sql mode
- [2025-01-02 22:50:09] INFO: extract data ..
- [2025-01-02 22:50:09] ERROR: dai query failed: CREATE TABLE _t_27b2cd44524e4603ab662d4e0a2841b8 AS SELECT
- date,
- instrument
- FROM
- cn_stock_bar1d
- JOIN cn_stock_basic_info USING (instrument)
- JOIN cn_stock_factors_base USING(date, instrument)
- JOIN cn_stock_status USING(date, instrument)
- WHERE
- (cn_stock_bar1d.instrument LIKE '%.SH' OR cn_stock_bar1d.instrument LIKE '%.SZ')
- AND cn_stock_basic_info.list_sector IN (1, 2)
- AND (cn_stock_factors_base.is_zz500 == 1 OR cn_stock_factors_base.is_szzs == 1 OR cn_stock_factors_base.is_cybz == 1 OR cn_stock_factors_base.is_szcz == 1 OR cn_stock_factors_base.is_sh50 == 1 OR cn_stock_factors_base.is_kc50 == 1 OR cn_stock_factors_base.is_hs300 == 1 OR cn_stock_factors_base.is_zz1000 == 1 OR cn_stock_factors_base.is_zz100 == 1 OR cn_stock_factors_base.is_sz100 == 1)
- AND cn_stock_status.st_status IN (0,)
- AND cn_stock_factors_base.margin_trading_status IN (0,)
- AND cn_stock_factors_base.suspended = 0
- QUALIFY
- 1 = 1
- ORDER BY date, instrument;
- SELECT
- c_rank(volume) AS rank_volume,
- close / m_lag(close, 1) as return_0,
- float_market_cap AS score,
- -- 日期和股票代码
- date, instrument
- FROM
- cn_stock_prefactors
- WHERE
- -- WHERE 过滤,在窗口等计算算子之前执行
- -- 剔除ST股票
- st_status = 0
- QUALIFY
- -- QUALIFY 过滤,在窗口等计算算子之后执行,比如 m_lag(close, 3) AS close_3,对于 close_3 的过滤需要放到这里
- -- 去掉有空值的行
- COLUMNS(*) IS NOT NULL
- -- 按日期和股票代码排序,从小到大
- ORDER BY date, instrument
- limit 10
- 您可以去社区论坛问答交流板块反馈咨询 去发帖>> --------------------------------------------------------------------------- PermissionException Traceback (most recent call last) Cell In[7], line 80 68 m1 = M.cn_stock_basic_selector.v8( 69 exchanges=["""上交所""", """深交所"""], 70 list_sectors=["""主板""", """创业板"""], (...) 76 m_name="""m1""" 77 ) 79 # @module(position="-315,-731", comment="""因子特征""") ---> 80 m2 = M.input_features_dai.v30( 81 input_1=m1.data, 82 mode="""SQL""", 83 expr_tables="""cn_stock_prefactors_community""", 84 extra_fields="""date, instrument""", 85 order_by="""date, instrument""", 86 expr_drop_na=False, 87 sql="""SELECT 88 c_rank(volume) AS rank_volume, 89 close / m_lag(close, 1) as return_0, 90 float_market_cap AS score, 91 -- 日期和股票代码 92 date, instrument 93 FROM 94 cn_stock_prefactors 95 WHERE 96 -- WHERE 过滤,在窗口等计算算子之前执行 97 -- 剔除ST股票 98 st_status = 0 99 QUALIFY 100 -- QUALIFY 过滤,在窗口等计算算子之后执行,比如 m_lag(close, 3) AS close_3,对于 close_3 的过滤需要放到这里 101 -- 去掉有空值的行 102 COLUMNS(*) IS NOT NULL 103 -- 按日期和股票代码排序,从小到大 104 ORDER BY date, instrument 105 limit 10""", 106 extract_data=True, 107 m_name="""m2""" 108 ) 110 # @module(position="-247,-607", comment="""持股数量、打分到仓位""") 111 m3 = M.score_to_position.v4( 112 input_1=m2.data, 113 score_field="""score DESC""", (...) 126 m_name="""m3""" 127 ) File /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/bigmodule/modules.py:28, in call(self, **kwargs) File /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/bigmodule/moduleinvoker.py:203, in module_invoke(name, version, kwargs) File /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/bigmodule/moduleinvoker.py:169, in _module_invoke(name, version, kwargs) File /opt/pyenv/versions/3.11.8/lib/python3.11/site-packages/bigmodule/moduleinvoker.py:41, in _module_run(module, kwargs) File dist/build/input_features_dai/v30/init.py:301, in v30.run() File dist/build/input_features_dai/v30/init.py:225, in v30._create_ds_from_sql() File dist/build/input_features_dai/v30/init.py:222, in v30._create_ds_from_sql() File /var/app/enabled/dai/_telemetry.py:191, in wrapper(*args, **kwargs) File /var/app/enabled/dai/_functions.py:360, in query(sql, udf_list, full_db_scan, filters, bind_relations) PermissionException: Permission Error: 请在查询表 cn_stock_bar1d 时使用 filters 参数指定分区范围(一般为 date 或 instrument ):dai.query(sql, filters={"date": ["2020-01-01", "2020-02-01"]})。若确需全表扫描,请设置 full_db_scan 参数:dai.query(sql, full_db_scan=True)
代码如下:
SELECT
c_rank(volume) AS rank_volume,
close / m_lag(close, 1) as return_0,
float_market_cap AS score,
-- 日期和股票代码
date, instrument
FROM
cn_stock_prefactors
WHERE
-- WHERE 过滤,在窗口等计算算子之前执行
-- 剔除ST股票
st_status = 0
QUALIFY
-- QUALIFY 过滤,在窗口等计算算子之后执行,比如 m_lag(close, 3) AS close_3,对于 close_3 的过滤需要放到这里
-- 去掉有空值的行
COLUMNS(*) IS NOT NULL
-- 按日期和股票代码排序,从小到大
ORDER BY date, instrument
limit 10