0

When trying to create a distributed table with Citus, it gives a PG::UndefinedColumn: ERROR: column "x" does not exist

I have enabled Citus on workers and main DB:

SELECT run_command_on_workers($cmd$
  CREATE EXTENSION citus;
$cmd$);

I created a composite primary key:

ActiveRecord::Base.connection.execute("
  ALTER TABLE x DROP CONSTRAINT x_pkey CASCADE;
")
ActiveRecord::Base.connection.execute("
  ALTER TABLE x ADD PRIMARY KEY (tenant_id, id);
")

When trying to do:

ActiveRecord::Base.connection.execute("
SELECT create_distributed_table(x, tenant_id);
")

It keeps saying:

ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR:  column "x" does not exist
LINE 2: SELECT create_distributed_table(x, tenant_id...
                                        ^
Caused by PG::UndefinedColumn: ERROR:  column "x" does not exist

Is there something I am forgetting?

heldopslippers
  • 828
  • 2
  • 9
  • 20

1 Answers1

1

The table name and column name need to be passed as text values in single quotes: SELECT create_distributed_table('x', 'tenant_id');

Marco Slot
  • 401
  • 3
  • 5