Add foreign key validation in Collection
还没有人认领这个 Issue。
评估
调研方向
从 Schema 和 Collection 入口点开始,然后检查 issue 中描述的现有 require_relationship_one_to_at_least_one 和 @dy.filter 行为。将所请求的声明与 sqlmodel 的 foreign_key 方法进行比较。完成的标准是 collection 成员可以声明引用,并且缺失的被引用键会引发 assertion,而不是被静默过滤;没有指定文件或测试。
由索引模型根据 Issue 内容生成。
描述
Lets say you have this basic example:
class Country(dy.Schema):
country_code = dy.String(primary_key=True)
capital = dy.String()
class CountryPair(dy.Schema):
a_country_code = dy.String(primary_key=True)
b_country_code = dy.String(primary_key=True)
distance = dy.Float64()
class MyCollection(dy.Collection):
"""Collection of all input tables for DMU balancing optimization."""
country: dy.LazyFrame[Country]
country_pair: dy.LazyFrame[CountryPair]
You might want to check/assert that a_country_code and b_country_code are present in Country.country_code.
Today you can use require_relationship_one_to_at_least_one but this will not raise a Expection but only filter.
And I would like to have something that is closer to my Collection definition. I tried to add in my Collection:
@dy.filter()
def at_least_one_diagnosis_per_invoice(self) -> pl.LazyFrame:
return self.country.select(pl.col.country_code.name.prefix("a_")).join(
self.country_pair,
on="a_country_code",
how="inner",
)
# But it fails with: ImplementationError: Members of a collection must have an overlapping primary key but did not find any
But even if this worked, I am more interesting into an assertion rather than a filter.
Do you think we can add support for foreign_key in the same manner this is done by sqlmodel
Exmaple:
class Country(dy.Schema):
country_code = dy.String(primary_key=True)
capital = dy.String()
class CountryPair(dy.Schema):
a_country_code = dy.String(primary_key=True, foreign_key="country.country_code") # reference Collection attribute
b_country_code = dy.String(primary_key=True, foreign_key="country.country_code") # reference Collection attribute
distance = dy.Float64()
class MyCollection(dy.Collection):
"""Collection of all input tables for DMU balancing optimization."""
country: dy.LazyFrame[Country]
country_pair: dy.LazyFrame[CountryPair]
- 主要语言
- Python
- 星标
- 618
- 派生
- 21
- 平均合并
- 14 小时 34 分钟
- 30 天内合并 PR
- 7
环境准备
我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Quantco/dataframely 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
Quantco/dataframely#402 · 3 条评论 ·
-
难度 3/5 1-2 天 新手友好度 62/100
Quantco/dataframely#357 · 1 个 reaction ·
-
难度 5/5 一周以上 新手友好度 25/100
Quantco/dataframely#309 · 4 条评论 · 2 个 reaction ·
-
难度 5/5 一周以上 新手友好度 45/100
Quantco/dataframely#273 · 5 条评论 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 45/100
Quantco/dataframely#272 · 10 条评论 · 1 个 reaction ·
查看 Quantco/dataframely 的全部 Issue
相似的 Issue
-
good first issue
难度 2/5 1-3 小时 新手友好度 88/100
-
难度 2/5 1-3 小时 新手友好度 88/100
vllm-project/vllm-metal#822 ·
维护者通常 1 天内回复
-
vector-store
难度 1/5 1-3 小时 新手友好度 90/100
维护者通常 1 天内回复
-
[Bug]: chunk_span_bounds and _validated_chunk_spans reject Pydantic models ChunkSpan and AudioFile未关闭
难度 2/5 1-3 小时 新手友好度 78/100
BasedHardware/omi#19047 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复