Example:
(1304): 01b9e9c5-0004-7f54-0002-28df00d5eaaa: 100132 (P0000): JavaScript execution error: Uncaught Error: Invalid argument: RAI_RELATION must be an empty relation in CREATE_DATA_STREAM at ' throw e;' position 8
stackstrace: err line: 395
errArg line: 400
ensureRelationIsEmpty line: 98
main line: 24
CREATE_DATA_STREAM line: 50
Explanation
This error is thrown when you are creating a stream, if your PyRel model (the RAI database) still contains any relations or data for that stream.
Resolution
Several options for resolving this are below, listed in order of severity.
Force Create
You can force the recreation of the stream with a command like the below:
app.create_streams(["my_db.my_schema.my_table"], "EntityResolution", force=True)
If this is successful, simply continue with your workflow.
It may fail with an error like the one below. If so, try another resolution.
(1304): 01b9e9ce-0004-7f54-0002-28df00d5ed4a: 100132 (P0000): JavaScript execution error: Uncaught Error: Error adding reference to the application: the a reference to the table/view has already been added. If there are existing Data Streams on the same source object in the process of being deleted or failed to be deleted, ensure they are completely deleted before creating more Data Streams on the same source object. Error: Uncaught exception of type 'EXPRESSION_ERROR' on line 9 at position 23 : Table 'my_db.my_schema.my_table' has already been added to the multi-valued reference definition 'DATA_STREAM_TABLE'. The same object cannot be added more than once. in CREATE_DATA_STREAM at ' throw e;' position 8
stackstrace: err line: 395
createDataStreamObjects line: 311
main line: 36
CREATE_DATA_STREAM line: 50
Delete and Recreate
In Python
Try deleting the data stream.
provider = rai.Provider()
provider.delete_stream("my_db.my_schema.my_table", model="MyModel")
This will delete the previous stream. However, even after deleting the stream, models retain access to a snapshot of the most recent data processed by the stream. If you are creating a data stream with the same name as a previously deleted stream, you must set the force parameter to TRUE in order to overwrite the data in the snapshot:
provider = rai.Provider()
provider.create_streams(["my_db.my_schema.my_table"], "MyModel", force=True)
If it fails with a message like the one below, then there is an metadata issue. Try a more serious resolution below.
(1304): 01b9e9cc-0004-7f54-0002-28df00d5ec6a: 100132 (P0000): JavaScript execution error: Uncaught Error: Data stream does not exist for the provided source (ROCREPRO.PUBLIC.PEOPLE) and target RAI DB (EntityResolution)
in DELETE_DATA_STREAM at ' throw e instanceof RAIError ? e : err("Error
deleting data stream", e);' position 8
stackstrace: err line: 94
DELETE_DATA_STREAM line: 64
Create Stream in SQL
Create the stream with a SQL command instead. Being closer to the database level, this can work around some issues that can be hit if it is called on the CLI or in Python.
CALL relationalai.api.create_data_stream(
relationalai.api.object_reference('TABLE', "my_db.my_schema.my_table"), -- Source table's type and name
'my_model', -- model name
"my_stream", -- stream name
TRUE -- force overwrite any existing stream
);
Delete the RAI Database
When all else fails, you can delete your RAI database (the RAI model database) with the command below.
CALL api.delete_database('my_db');
This removes all data in the RAI database, including metadata about the stream. Next you will need to recreate the database, and recreate the stream.