Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YCQL] system_schema.functions undefined column 'body' #3893

Closed
ybnelson opened this issue Mar 10, 2020 · 4 comments
Closed

[YCQL] system_schema.functions undefined column 'body' #3893

ybnelson opened this issue Mar 10, 2020 · 4 comments
Assignees
Labels
2.20 Backport Required 2024.1 Backport Required area/ycql Yugabyte CQL (YCQL) community/request Issues created by external users kind/enhancement This is an enhancement of an existing feature priority/medium Medium priority issue

Comments

@ybnelson
Copy link

ybnelson commented Mar 10, 2020

Jira Link: DB-4672
For migrating Cortex, https://github.com/yugabyte/cortex, a project which uses CQL and Cassandra 3.11, it expects the following layout of system_schema.functions:

cqlsh> SELECT * FROM system_schema.functions;

 keyspace_name | function_name | argument_types | argument_names | body | called_on_null_input | language | return_type
---------------+---------------+----------------+----------------+------+----------------------+----------+-------------
cqlsh> DESCRIBE system_schema.functions;
CREATE TABLE system_schema.functions (
    keyspace_name text,
    function_name text,
    argument_types frozen<list<text>>,
    argument_names frozen<list<text>>,
    body text,
    called_on_null_input boolean,
    language text,
    return_type text,
    PRIMARY KEY (keyspace_name, function_name, argument_types)
) WITH CLUSTERING ORDER BY (function_name ASC, argument_types ASC)
    AND bloom_filter_fp_chance = 0.01
    AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
    AND comment = 'user defined function definitions'
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
    AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
    AND crc_check_chance = 1.0
    AND dclocal_read_repair_chance = 0.0
    AND default_time_to_live = 0
    AND gc_grace_seconds = 604800
    AND max_index_interval = 2048
    AND memtable_flush_period_in_ms = 3600000
    AND min_index_interval = 128
    AND read_repair_chance = 0.0
    AND speculative_retry = '99PERCENTILE';

From YBDB 2.1.1 instance:

cqlsh> SELECT * FROM system_schema.functions;

 keyspace_name | function_name | argument_types | argument_names | called_on_null_input | language | return_type
---------------+---------------+----------------+----------------+----------------------+----------+-------------

Error generated:
level=error ts=2020-03-09T20:12:31.75034073Z caller=table_manager.go:188 msg="error syncing tables" err="Undefined Column. Column doesn't exist\n\n\t\tSELECT\n\t\t\tfunction_name,\n\t\t\targument_types,\n\t\t\targument_names,\n               ^^^\n\t\t\tbody,\n^^^^\n\t\t\tcalled_on_null_input,\n\t\t\tlanguage,\n\t\t\treturn_type\n\t\tFROM system_schema.functions\n\t\tWHERE keyspace_name = ?\n (ql error -203)"
@yugabyte-ci yugabyte-ci added the community/request Issues created by external users label Mar 10, 2020
@kmuthukk
Copy link
Collaborator

@yb-andrew

This worked fine for me in 2.0.10.

cqlsh> SELECT * FROM system_schema.functions;

 keyspace_name | function_name | argument_types | argument_names | called_on_null_input | language | return_type
---------------+---------------+----------------+----------------+----------------------+----------+-------------

(0 rows)
cqlsh> exit

I don't see the error you are seeing. Can you double check if it is specific to 2.1.1 and not 2.0.10 (that I tried)?

Also, the PRIMARY KEY is different in YugabyteDB. It has two columns (as shown below), whereas in the output you showed (is that from Apache Cassandra?) -- the PRIMARY KEY has three columns.

CREATE TABLE system_schema.functions (
    keyspace_name text,
    function_name text,
    argument_types list<text>,
    argument_names list<text>,
    called_on_null_input boolean,
    language text,
    return_type text,
    PRIMARY KEY (keyspace_name, function_name)
) WITH CLUSTERING ORDER BY (function_name ASC)

@kmuthukk kmuthukk changed the title system_schema.functions undefined column 'body' [YCQL] system_schema.functions undefined column 'body' Mar 10, 2020
@ybnelson
Copy link
Author

The given 'select...' command completes successfully, but the cortexproject (table_manager.go) is expecting a 'body' column which is not present in the Yugabyte 2.0.10 or 2.1.1 when it tries to query its cassandra data source.
I added the table spec from a Cassandra 3.11 instance for comparison. Only the body column is missing from the Yugabyte implementation. If you have docker installed, you can verify with:
docker run -d --name cassandra --rm -p 9042:9042 cassandra:3.11
Then run cqlsh against that local instance on 127.0.0.1
cqlsh> select * from system_schema.functions;

@marcusbooyah
Copy link

I'm working on getting Cortex to work on Yugabyte right now and ran into the same issue, as well as another discrepancy. The other is that system_schema.aggregates is missing the return_type column of type TEXT.

Is the plan here to add these columns? I'd happily make the changes and submit a PR.

@bmatican
Copy link
Contributor

bmatican commented Aug 6, 2020

Good note @marcusbooyah ! This sounds like a relatively simple change to do, we'd be happy to take in a PR for it!

Looking back, we did setup an upgrade path, specifically to cover for such changes in the future, in case the system table situation evolved. Here's an example commit doing just that, albeit a long time back: 2a4fb09

cc @m-iancu

marcusbooyah added a commit to neonforge-forks/yugabyte-db that referenced this issue Jan 12, 2021
…w match Cassandra

Added field `body` to `system_schema.functions`
Added field `return_type` to `system_schema.aggregates`
Added `argument_types` to the primary key for `system_schema.funtions` and `system_schema.aggregates`
`argument_types` is now a frozen list in `system_schema.functions` and `system_schema.aggregates`
@rthallamko3 rthallamko3 added the area/ycql Yugabyte CQL (YCQL) label Dec 29, 2022
@yugabyte-ci yugabyte-ci added kind/bug This issue is a bug priority/medium Medium priority issue labels Dec 29, 2022
@yugabyte-ci yugabyte-ci added kind/enhancement This is an enhancement of an existing feature and removed kind/bug This issue is a bug labels Sep 10, 2024
OlegLoginov added a commit that referenced this issue Sep 11, 2024
Summary:
Original fix: neonforge-forks@e775a10

The fix updates the schema for 2 virtual (always empty) YCQL tables:
1. Table `system_schema.functions`:
  - Added field `body` (type TEXT).
  - `argument_types` is now a FROZEN LIST of TEXT.
  - Added `argument_types` to the primary key.
  - `argument_names` is now a FROZEN LIST of TEXT.

2. Table `system_schema.aggregates`:
  - `argument_types` is now a FROZEN LIST of TEXT.
  - Added `argument_types` to the primary key.
  - Added field `return_type` (type TEXT).

Test Plan:
./yb_build.sh --java-test org.yb.cql.TestSystemTables#testSystemTableColumns
./yb_build.sh --java-test org.yb.cql.TestSystemTables#testEmptySystemTables

Reviewers: mihnea, stiwary, skumar

Reviewed By: stiwary

Subscribers: smishra, ybase, yql

Differential Revision: https://phorge.dev.yugabyte.com/D37909
jasonyb pushed a commit that referenced this issue Sep 12, 2024
Summary:
 f5ad1fb [#23855] Fixing the calculation of automatic refactoring count.
 eed826d [#22519] YSQL: Move ExplicitRowLockBuffer class into separate file
 99a27e6 [PLAT-14522] Taking yba-ctl backups with prometheus HTTPS
 e2a84b0 [PLAT-15044] Add preflight check for node addition in provider
 7e40d89 [#20769] XCluster: Dynamically apply cdc_wal_retention_time_secs for XCluster
 aa41478 [#23858] build: fix ./yb_build.sh release --gcc11
 bcf7f47 [PLAT-13910] Improve IAM credentials fetch logging and add retries
 303a202 [#23778] xCluster: Remove the capability to rename xCluster replication groups
 Excluded: 58fd26e [#23652] YSQL: Fix TestPgRegressAnalyze.java timeout / database drop failure on TSAN build
 31da65b [doc] yb_enable_bitmapscan flag (#23854)
 798db14 [#20335] DocDB: Use MonoClock for write query metric
 80779d8 [#23860] xCluster: Add automatic ddl mode proto fields
 afd763d Revert "Revert "[PLAT-14786] Add support to node_agent install to use bind ip and node_external_fqdn""
 e86951a [#23841] docdb: Disable stack trace tracking in TSAN builds
 d600608 [PLAT-15244] Fix schedule not getting updated on edit schedule API call
 3c0df09 [PLAT-15214][PLAT-15232]YBC version upgrade to 2.2.0.0-b6 and enable YBC verbose by default
 aa7372e [#23478] YSQL: fix connection manager session variable case sensitivity issue
 0d53558 [PLAT-14810][PLAT-14811][YBA CLI] Support adding and editing EIT configurations
 ffa537e [PLAT-10706][dr] Support retry-ability of failover and switchover
 Excluded: 5ae4558 [#23578] YSQL: Add HELP and TYPE to :13000/prometheus-metrics
 3aa7459 [PLAT-15016] Handle gflag_group changes for ENHANCED_PG_COMPATIBILITY group in 2024.1.3
 c89356c [PLAT-10592][YBA] Changes to support global tserver/master service in K8s
 7fc3b76 [#3893] YCQL: Align 2 system_schema.* tables with Cassandra
 da6274e [23646] Test Stability: Fix PgMiniTest.FollowerReads
 5fa6dc9 [PLAT-15180][Platform][UI][PITR]Create Restore Backup modal
 be0d1d1 [PLAT-15247][Platform][Backup]Create Backup scheduled policy List

Test Plan: Jenkins: rebase: pg15-cherrypicks

Reviewers: jason, tfoucher

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D37981
OlegLoginov added a commit that referenced this issue Sep 12, 2024
…ssandra

Summary:
Original diff: 7fc3b76 / D37909

Original fix: neonforge-forks@e775a10

The fix updates the schema for 2 virtual (always empty) YCQL tables:
1. Table `system_schema.functions`:
  - Added field `body` (type TEXT).
  - `argument_types` is now a FROZEN LIST of TEXT.
  - Added `argument_types` to the primary key.
  - `argument_names` is now a FROZEN LIST of TEXT.

2. Table `system_schema.aggregates`:
  - `argument_types` is now a FROZEN LIST of TEXT.
  - Added `argument_types` to the primary key.
  - Added field `return_type` (type TEXT).
Jira: DB-4672

Test Plan:
./yb_build.sh --java-test org.yb.cql.TestSystemTables#testSystemTableColumns
./yb_build.sh --java-test org.yb.cql.TestSystemTables#testEmptySystemTables

Reviewers: mihnea, stiwary, skumar

Reviewed By: stiwary

Subscribers: yql, ybase, smishra

Differential Revision: https://phorge.dev.yugabyte.com/D37974
OlegLoginov added a commit that referenced this issue Sep 12, 2024
…andra

Summary:
Original diff: 7fc3b76 / D37909

Original fix: neonforge-forks@e775a10

The fix updates the schema for 2 virtual (always empty) YCQL tables:
1. Table `system_schema.functions`:
  - Added field `body` (type TEXT).
  - `argument_types` is now a FROZEN LIST of TEXT.
  - Added `argument_types` to the primary key.
  - `argument_names` is now a FROZEN LIST of TEXT.

2. Table `system_schema.aggregates`:
  - `argument_types` is now a FROZEN LIST of TEXT.
  - Added `argument_types` to the primary key.
  - Added field `return_type` (type TEXT).
Jira: DB-4672

Test Plan:
./yb_build.sh --java-test org.yb.cql.TestSystemTables#testSystemTableColumns
./yb_build.sh --java-test org.yb.cql.TestSystemTables#testEmptySystemTables

Reviewers: mihnea, stiwary, skumar

Reviewed By: stiwary

Subscribers: yql, ybase, smishra

Differential Revision: https://phorge.dev.yugabyte.com/D37976
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.20 Backport Required 2024.1 Backport Required area/ycql Yugabyte CQL (YCQL) community/request Issues created by external users kind/enhancement This is an enhancement of an existing feature priority/medium Medium priority issue
Projects
Status: Done
Development

No branches or pull requests

9 participants