OHDSI Home | Forums | Wiki | Github

ERROR: relation "results.achilles_results" does not exist

This is my last step (hopefully) of the work in the last two weeks - I did setup WebAPI, Atlas and backend CDM tables, and now I am loading Achilles in R, and encounter this error message:

DBMS:

postgresql

Error:

org.postgresql.util.PSQLException: ERROR: relation "results.achilles_results" does not exist

SQL:

create index idx_ar_aid on results.achilles_results (analysis_id)

R version:

R version 4.0.4 (2021-02-15)

Platform:

x86_64-apple-darwin17.0

Attached base packages:

- stats

- graphics

- grDevices

- utils

- datasets

- methods

- base

Other attached packages:

- Achilles (1.6.7)

- DatabaseConnector (3.0.0)

- devtools (2.3.2)

- usethis (2.0.1)

- rJava (0.9-13)

And here is what I have:

my CDM database backend:
cdm schema which contains the cdm and vocab tables
results schema, which is completely separate from cdm schema

then, I used this URL:

http://localhost:8089/WebAPI/ddl/results?dialect=postgresql&schema=results&vocabSchema=cdm&tempSchema=temp&initConceptHierarchy=true

to generate a long DDL script, and then I ran this script manually and created lots of tables under results schema (this is the step I am not sure about).

After all these, I followed the steps described here to install Achilles using R, and here are my two main steps:

connectionDetails <- createConnectionDetails(
dbms=“postgresql”,
server=“localhost/synpuf_CDM”,
user=“postgres”,
password=“xxxx”,
port=“5432”)

achilles(connectionDetails,
cdmDatabaseSchema = “cdm”,
resultsDatabaseSchema=“results”,
vocabDatabaseSchema = “cmd”,
numThreads = 1,
sourceName = “synpuf_CDM”,
cdmVersion = “5”,
runHeel = FALSE,
runCostAnalysis = FALSE)

and then I got this error:

Error:

org.postgresql.util.PSQLException: ERROR: relation "results.achilles_results" does not exist

and I do have some other error reports, for example,

-rw-r--r--    1 yul09  staff   888 Mar  1 15:11 achillesError_1425.txt
-rw-r--r--    1 yul09  staff  1042 Mar  1 16:03 achillesError_900.txt
-rw-r--r--    1 yul09  staff  1033 Mar  1 16:03 achillesError_901.txt
-rw-r--r--    1 yul09  staff  1339 Mar  1 16:03 achillesError_902.txt
-rw-r--r--    1 yul09  staff  2251 Mar  1 16:03 achillesError_903.txt
-rw-r--r--    1 yul09  staff  1515 Mar  1 16:03 achillesError_904.txt
-rw-r--r--    1 yul09  staff  1073 Mar  1 16:03 achillesError_906.txt
-rw-r--r--    1 yul09  staff  2607 Mar  1 16:03 achillesError_907.txt
-rw-r--r--    1 yul09  staff   990 Mar  1 16:03 achillesError_909.txt
-rw-r--r--    1 yul09  staff   812 Mar  1 16:03 achillesError_910.txt
-rw-r--r--    1 yul09  staff  1262 Mar  1 16:03 achillesError_920.txt
-rw-r--r--    1 yul09  staff  1075 Mar  1 16:03 achillesError_1000.txt
-rw-r--r--    1 yul09  staff  1066 Mar  1 16:03 achillesError_1001.txt
-rw-r--r--    1 yul09  staff  1392 Mar  1 16:03 achillesError_1002.txt
-rw-r--r--    1 yul09  staff  2280 Mar  1 16:03 achillesError_1003.txt
-rw-r--r--    1 yul09  staff  1568 Mar  1 16:03 achillesError_1004.txt
-rw-r--r--    1 yul09  staff  1126 Mar  1 16:03 achillesError_1006.txt
-rw-r--r--    1 yul09  staff  2646 Mar  1 16:03 achillesError_1007.txt
-rw-r--r--    1 yul09  staff  1012 Mar  1 16:03 achillesError_1009.txt
-rw-r--r--    1 yul09  staff   834 Mar  1 16:03 achillesError_1010.txt
-rw-r--r--    1 yul09  staff  1305 Mar  1 16:03 achillesError_1020.txt
-rw-r--r--    1 yul09  staff  7602 Mar  1 16:03 achillesError_1900.txt
-rw-r--r--    1 yul09  staff   838 Mar  1 16:03 achillesError_2200.txt
-rw-r--r--    1 yul09  staff   832 Mar  1 16:03 achillesError_2201.txt
-rw-r--r--    1 yul09  staff   484 Mar  1 16:03 errorReportSql.txt
drwxr-xr-x    4 yul09  staff   128 Mar  1 16:03 output

for example, 1425.txt says this,

DBMS:
postgresql

Error:
org.postgresql.util.PSQLException: ERROR: column "payer_source_concept_id" does not exist
  Position: 116

SQL:
--HINT DISTRIBUTE_ON_KEY(stratum_1)
CREATE TEMP TABLE s_tmpach_1425 
  
AS
SELECT
1425 as analysis_id,
       cast(payer_source_concept_id AS varchar(255)) AS stratum_1,
       cast(null AS varchar(255)) AS stratum_2,
       cast(null as varchar(255)) as stratum_3,
       cast(null as varchar(255)) as stratum_4,
       cast(null as varchar(255)) as stratum_5,
       COUNT(*) AS count_value
  
FROM
cdm.payer_plan_period
 group by payer_source_concept_id

R version:
R version 4.0.4 (2021-02-15)

Can someone please kindly let me know which part I did wrong? really appreciated any help I can get.

Thanks!

Check the database configuration,Achilles can only connect to the cdm database instead of the webapi database ,and make sure that the cdm table has available data.If all goes well,You can clear the results database first,then execute Achilles and finally execute the sql script last.

Please follow the instructions below, maybe you will find the missing step.

The DDL from WebAPI is a different set of tables than the tables created in the Achilles package. The only connection to WebAPi and Achilles is that if you write the Achilles tables to WebAPI’s results schema, WebAPI can read those tables for the ‘Data Sources’ section of Atlas.

Achilles should build the necessary tables, so it is strange that you get a ‘table does not exist’ when it’s tryign to build the index.

Hi @Chris_Knoll,

Thank you for the help and explanation, as always.

I solved the problem, and let me share what I did here, so if anyone has the same issue, at least this is one thing she/he can try.

This error message,

org.postgresql.util.PSQLException: ERROR: relation "results.achilles_results" does not exist

is actually due to some other issues, which prevent it from being created successfully, and once we fix those other issues, the problem will go away and results.achilles_results table will be created.

How do you know what are the other issues? There are some txt documents created and there is also a log file, which can all be used as a clue about what these other issues are. For example, one txt file tells me the following issue:

DBMS:

postgresql

Error:

org.postgresql.util.PSQLException: ERROR: relation "cdm.specimen" does not exist

Position: 5180

SQL:

--HINT DISTRIBUTE_ON_KEY(stratum_1)

CREATE TEMP TABLE s_tmpach_1900

so I know I am missing this cdm.specimen table, which I can add it right away. Once I did that, this particular issue is fixed. By the way, the reason I did not have that table at the first place was because I was using the synpuf test dataset and I thought this specimen table was not needed.

Again, we just need to clear all the issues, one by one. Once all the issues are gone, the results table will be create and you can see the Data Source in Atlas. Since we are on this topic, I had one issue like this,

DBMS:
postgresql

Error:
org.postgresql.util.PSQLException: ERROR: column de.drug_era_start_date does not exist
  Position: 454

SQL:
--HINT DISTRIBUTE_ON_KEY(stratum_1)
CREATE TEMP TABLE s_tmpach_901

AS
SELECT
901 AS analysis_id,
        CAST(de.drug_concept_id AS VARCHAR(255)) AS stratum_1,
        CAST(NULL AS VARCHAR(255)) AS stratum_2,
        CAST(NULL AS VARCHAR(255)) AS stratum_3,
        CAST(NULL AS VARCHAR(255)) AS stratum_4,
        CAST(NULL AS VARCHAR(255)) AS stratum_5,
        COUNT(de.person_id) AS count_value

FROM
cdm.drug_era de

Note de is alias of cmd.drug_era. So is this some kind of version error? apparently, in my cdm.drug_era table, I had a field called column de.drug_era_start_datetime, but it was de.drug_era_start_date that Achilles tool is looking for. And I did specified cdmVersion = “5” … so this is still a big mystery to me.

One last question - I never truly understand about the DDL scripts generated by using this URL:

http://localhost:8089/WebAPI/ddl/results?dialect=postgresql&schema=results&vocabSchema=cdm&tempSchema=temp&initConceptHierarchy=true

exactly when should we use the generated DDL scripts?

Thanks,
liyang

@UltraXiaoZi, thank you! I saved your document, wished I had it earlier!

One last question - I never truly understand about the DDL scripts generated by using this URL:

http://localhost:8089/WebAPI/ddl/results?dialect=postgresql&schema=results&vocabSchema=cdm&tempSchema=temp&initConceptHierarchy=true

exactly when should we use the generated DDL scripts?

Once you are ready to deploy a CDM database in Atlas, you will need to run these DDL scripts in the CDM source’s results schema. This is where cohort generation information is written.

@Ajit_Londhe, thank you for clearing that!! so these scripts are NOT needed by Achilles?

Right, don’t worry about running those statements from the results endpoint in WebAPI until you’re ready to deploy the source to Atlas. Achilles is a self-contained package, no need to create any tables ahead of time. If it tells you that achilles_results didn’t get created, it’s because 1 or more of the underlying analysis queries failed.

@Ajit_Londhe, nice!! got it, got it. This is very helpful information, and thank you for confirming that!

1 Like

Hi All,

i am getting the below error for one of the analysis.
could you tell me if there is any fix for this.

DBMS:
redshift

Error:
java.sql.SQLException: Amazon Invalid operation:
This type of correlated subquery pattern is not supported due to internal error;

SQL:
–HINT DISTRIBUTE_ON_KEY(stratum_1)

CREATE TABLE #s_tmpach_11

because of this error the final table achilles_results dint get created.

t