What's New in Version 1.0.18
Version 1.0.18 of the relationalai Python package is now available!
To upgrade, activate your virtual environment and run the following command:
pip install --upgrade relationalaiNew Features and Enhancements
Section titled “New Features and Enhancements”-
You can now pass an existing Snowpark session to
create_config()withsnowflake_session=.For example:
from snowflake.snowpark import Sessionfrom relationalai.config import create_configsnowflake_connection_parameters = {...}snowpark_session = Session.builder.configs(snowflake_connection_parameters).create()config = create_config(snowflake_session=snowpark_session)assert config.get_session() is snowpark_sessionThis change makes it easier to use PyRel in environments where you already have a Snowpark session.
Bug Fixes
Section titled “Bug Fixes”-
Fixed nested lookups that could drop rows when the inner lookup had no match. Before, PyRel could skip rows instead of keeping the row and showing
NULLfor the missing value. For example:from relationalai.semantics import Integer, Model, Stringm = Model("CustomerModel")Customer = m.Concept("Customer", identify_by={"id": Integer})Customer.name = m.Property(f"{Customer} has name {String:name}")ReferralCode = m.Relationship(f"{Integer:customer_id} maps to {String:referral_code}")m.define(Customer.new(id=1, name="Alice"),Customer.new(id=2, name="Bob"),ReferralCode(1, "ABC123"))customer_id = Integer.ref()code = String.ref()q = (m.where(Customer.id == customer_id,referral_code := m.where(ReferralCode(customer_id, code)).select(code),).select(Customer.name, referral_code.alias("referral_code")))print(q.to_df())Output before the fix:
name referral_code0 Alice ABC123Output after the fix:
name referral_code0 Alice ABC1231 Bob NULL -
Fixed
datetime.date.range()anddatetime.datetime.range()when theendvalue comes from a DSL value like aConcept,PropertyorRelationshipinstead of a regular Python date or datetime. Before, the query could return one combined date range instead of a separate date range for each entity. For example:from relationalai.semantics import Date, Integer, Model, define, select, stdimport datetime as dtm = Model("dates")Foo = m.Concept("Foo", identify_by={"id": Integer})Foo.end_date = m.Property(f"{Foo} has {Date:end_date}")define(Foo.new(id=1, end_date=dt.date(2020, 1, 2)),Foo.new(id=2, end_date=dt.date(2020, 1, 4)),)select(std.datetime.date.range(dt.date(2020, 1, 1), Foo.end_date, freq="D")).to_df()Before, that query could return one combined date range instead of a separate date range for each
Foorow:# Before the fix:result0 2020-01-011 2020-01-022 2020-01-033 2020-01-04Now there are duplicate dates because both
Foorows contribute to the result:# After the fix:result0 2020-01-012 2020-01-023 2020-01-024 2020-01-035 2020-01-04 -
Fixed inferred field naming for numeric aliases such as
Integer. Before, if you let PyRel infer a field name from one of those types, it would generate a name likenumber_38_0instead ofinteger, so string lookups such asScores["integer"]would fail with aKeyErrorexception. For example:from relationalai.semantics import Integer, Model, Stringm = Model("scores")# The Integer field is unnamed here, so PyRel infers its field name.Scores = m.Relationship(f"{String:name} has {Integer}")# Prior to the fix, this lookup would raise a KeyError.m.select(Scores["integer"]).to_df()Now PyRel infers the correct field name, so
Scores["integer"]resolves to theIntegerfield.