Add foreign key validation in Collection
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Bắt đầu với các entry point của Schema và Collection, sau đó kiểm tra hành vi hiện có của require_relationship_one_to_at_least_one và @dy.filter được mô tả trong issue. So sánh khai báo được yêu cầu với cách tiếp cận foreign_key của sqlmodel. Hoàn thành nghĩa là các member của collection có thể khai báo các reference và các key được reference nhưng bị thiếu sẽ tạo ra một assertion thay vì bị lọc một cách âm thầm; không có file hoặc test nào được nêu tên.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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]
- Ngôn ngữ chính
- Python
- Star
- 618
- Fork
- 21
- Merge trung bình
- 14 giờ 34 phút
- Pull request đã merge (30 ngày)
- 7
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Quantco/dataframely
-
Expose validation errors Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Quantco/dataframely#402 · 3 bình luận ·
-
Adding `sorted` in `dy.Column` Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 62/100
Quantco/dataframely#357 · 1 reaction ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
Quantco/dataframely#309 · 4 bình luận · 2 reaction ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 45/100
Quantco/dataframely#273 · 5 bình luận · 1 reaction ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
Quantco/dataframely#272 · 10 bình luận · 1 reaction ·
Tất cả issue của Quantco/dataframely
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
stephrobert/dsoxlab#238 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
sublimehq/package_control#1780 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
nwg-piotr/nwg-displays#145 ·