Example Error Message
Uninitialized property
The properties person_id, address, email, phone have never been set or added to and so will always cause the rule or query to fail.
2 | with model.rule(dynamic=True):
3 | person1 = Person()
4 | person2 = Person()
5 | person1 < person2
6 | for (attribute, weight) in attribute_weights.items():
7 | with getattr(person1, attribute) == getattr(person2, attribute):
8 | pair = MatchPair.add(person1=person1, person2=person2)
9 | ExactAttributeMatch.add(pair=pair,
attribute=attribute).set(weight=weight)
This error message may also be accompanied with a message like the below, if the source is inaccessible:
Unknown Source
Unable to access Unable to access source 'TEST.PUBLIC.PEOPLE'. Ensure the source's fully qualified name is spelled correctly and that the role your program is executing with has permission to access it.
Explanation
This error indicates the model does not know where the property is coming from. Ensure the data exists and the model has access to it. There are a few methods to resolve this, depending on where the disconnect is.
As a useful debugging tool, you can call known_properties() on a Type to determine what properties are available to a model at that time. For example:
Person.known_properties()
0:"snowflake_id"
1:"person_id"
2:"name"
3:"address"
4:"email"
5:"phone"
If you expect to see more properties in the list at that point, be sure the source exists, and is defined, or that the property is declared. Note: you can call this directly after creating a Type with a source and if it errors, then it indicates the data source is inaccessible.
Resolutions
Ensure Data is Accessible
The table with the data may be inaccessible to the model. Double check the table exists and confirm it has the right permissions on it. From a Snowflake notebook, easily check which tables exist By selecting the Databases tab in the upper left.
Alternatively create a SQL cell and run a command like the below:
use LALONDE_DB;
show tables;
To check permissions in a SQL cell run a command like below:
use LALONDE_DB;
show grants on LALONDE_DB.TEST.TEST_TABLE;
If it doesn't exist you can run a CREATE TABLE statement to create it in SQL, or from a Snowflake notebook choose Create > Table > Source (eg: From File).
Check that the Stream Exists
Ensure you have a stream porting data from the table in Snowflake to your model in RelationalAI. If the stream does not exist yet, enable change tracking on the table with a command like the below, and then create the stream.
ALTER TABLE LALONDE_DB.TEST.TEST_TABLE SET CHANGE_TRACKING = TRUE;
app = rai.Provider()
app.create_streams(["LALONDE_DB.TEST.TEST_TABLE"], "My_Model")
Double Check the Property Name
Properties are declared implicitly when you use them within a context manager. This means you don't have to call declare() for every single property. However, if you use the wrong property name in a query it creates that property. Next when the model tries to query it, it will return the uninitialized property error since this brand new property has never been set.
In this example below I should have queried for the full name of the property email_address but accidentally used just email instead.
This can be confusing because if you check the known properties after that, the false property name now exists.
If you are programming in a notebook, restart the notebook to clear that false property off of the object type. Be sure to correct the property name in the cell where you are querying it.
Otherwise if you are programming locally, just correct the property name you are querying and rerun the script.
Initialize properties
This error can occur if you are executing queries against a model, but it has not seen the rules for the properties. In many cases you can skip initializing properties, because they are declared implicitly when you set them in a rule. For example when you call add(), set(), or extend() this implicitly initializes properties.
Otherwise, be sure to initialize single-valued properties using the declare()method, and has_many() method for multi-valued properties. Note: It is required to use the has_many() method for properties derived from Snowflake tables or views where a column contains multiple rows for the same primary key:
Note: The Error Does Not Occur Until Querying
The model does not actually touch the data when calculating rules. It is not until executing a query that the data is validated and sent through the model. This is because entities aren’t created until the model is queried. Therefore when developing code it is useful to periodically run simple queries to confirm the data is available and appears as expected up to that point.
For example: check what properties are available and pull a quick selection of 5 results.
Person.known_properties()
0:"snowflake_id"
1:"person_id"
2:"name"
3:"address"
4:"email"
5:"phone"
with model.query() as select:
p = Person()
aggregates.top(5, p)
response = select(p.person_id, p.name, p.address, p.email, p.phone)
response
If the query errors or returns unexpected results, check the rules that ran directly before it for issues.
Related Documentation
For more information see these documents.