AstroResearch/migrations/20260703120000_add_vizier_cache.sql
Asfmq a156252bc3 feat: 接入 VizieR 星表检索与 LAMOST/Gaia/SDSS/DESI 跨源光谱下载
新增天文观测数据获取能力,覆盖星表查询与一维光谱下载两大场景:

星表检索(CDS VizieR)
- VizieR TAP 客户端(JSON 优先 + VOTable 降级),共享 IVOA VOTable 解析层
- 业务层支持自由 ADQL、锥形检索、交叉证认、星表发现与 CSV 导出
- ADQL 注入防护(标识符清洗 + 字符串字面量转义),TTL 缓存(7 天)

跨望远镜光谱下载(统一入口)
- 接入 LAMOST(ConeSearch + FITS.gz)、Gaia(TAP + DataLink ZIP)、
  SDSS(Data Lab TAP + SAS)、DESI(HEALPix coadd)四源
- 双模式:坐标模式(cone 检索 → 选源 → 下载)/ 标识符模式(直按 ID 下载)
- 光谱文件永久缓存(不可变),按 source+source_id 去重

Agent 与 API
- +4 工具:query_vizier / cone_search / find_spectrum / catalog_operation(22 → 26)
- +6 路由:/catalog/vizier、/cone、/crossmatch、/spectrum/{download,list}
- 前端新增 VizierResultCard / FindSpectrumCard 可视化卡片

工程重构
- services/target.rs (832 行) 拆分为 services/cds/{target,vizier}.rs + clients/cds/sesame.rs,
  贯彻 client(通信)/ service(缓存+编排)分层
- ADS 返回字段新增 data(关联数据表 URL),与星表功能联动
2026-07-06 00:07:25 +08:00

15 lines
657 B
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- VizieR TAP / VO 查询结果本地缓存
-- 对齐 paper_targets 的缓存范式JSON 列存复杂结构、UNIQUE 约束、索引
CREATE TABLE IF NOT EXISTS vizier_query_cache (
id INTEGER PRIMARY KEY AUTOINCREMENT,
query_hash TEXT NOT NULL, -- sha1(adql + max_records)
adql TEXT NOT NULL,
max_records INTEGER,
result_json TEXT NOT NULL, -- 序列化后的 VizierQueryResult
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
expires_at DATETIME, -- TTL 过期时间NULL = 永不过期)
UNIQUE(query_hash)
);
CREATE INDEX IF NOT EXISTS idx_vizier_cache_hash ON vizier_query_cache(query_hash);