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

TTL Job Description does not quote Key Column #142986

Open
elizah18 opened this issue Mar 17, 2025 · 1 comment
Open

TTL Job Description does not quote Key Column #142986

elizah18 opened this issue Mar 17, 2025 · 1 comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. E-starter Might be suitable for a starter project for new employees or team members. good first issue T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)

Comments

@elizah18
Copy link

elizah18 commented Mar 17, 2025

Describe the problem

The schema uses quoted identifiers for Database, Schema, Table and Column names.

The description of a TTL job in the crdb_internal.jobs table and consequently the DB Console -> Jobs -> Job Detail page do not quote all column names. The Database, Schema and Table names are quoted correctly, it is just the PK column name(s) that is not.
This makes cutting and pasting the query for testing more complicated than it needs to be.

To Reproduce

CREATE DATABASE "CaseSensitiveDB";
USE "CaseSensitiveDB";

CREATE SCHEMA "CaseSensitiveSchema";

DROP TABLE IF EXISTS "CaseSensitiveSchema"."Dogs";
CREATE TABLE "CaseSensitiveSchema"."Dogs" (
      "Id" INT8 NOT NULL,
      "Name" VARCHAR NOT NULL,
      "Weight" FLOAT8 NULL,
      "CreatedDate" TIMESTAMPTZ,
      CONSTRAINT dogs_pkey PRIMARY KEY ("Id" ASC)
  ) WITH (
      ttl_expiration_expression = $$("CreatedDate" + INTERVAL '2 months')$$
    , ttl_job_cron = '*/1 * * * *'
);;

INSERT INTO "CaseSensitiveSchema"."Dogs" ("Id", "Name", "Weight", "CreatedDate")
SELECT 
    gs AS "Id",
    'Dog_' || gs AS "Name",
    random() * 50 + 5 AS "Weight",  -- Random weight between 5 and 55
    now() - (gs * INTERVAL '1 day') AS "CreatedDate"
FROM generate_series(1, 100) AS gs;  -- Generates 100 rows

-- wait for a minute

SELECT description
FROM crdb_internal.jobs
WHERE description like '%CaseSensitiveDB%'
order by finished desc limit 1;

--- The output shows the Id columns is not quoted.

                     description

ttl for "CaseSensitiveDB"."CaseSensitiveSchema"."Dogs"
-- for each span, iterate to find rows:
SELECT Id
FROM "CaseSensitiveDB"."CaseSensitiveSchema"."Dogs"
AS OF SYSTEM TIME INTERVAL '-30 seconds'
WHERE ((("CreatedDate" + INTERVAL '2 months')) <= $1)
AND (
(Id >= $3)
)
AND (
(Id <= $2)
)
ORDER BY Id ASC
LIMIT 500
-- then delete with:
DELETE FROM "CaseSensitiveDB"."CaseSensitiveSchema"."Dogs"
WHERE ((("CreatedDate" + INTERVAL '2 months')) <= $1)
AND (Id) IN (($2))
(1 row)

Expected behavior
All columns should be quoted as per the customers defined schema.

Additional data / screenshots

Screen shot of DB Console attached.

Image

If applicable, add screenshots to help explain your problem.

Environment:

  • CockroachDB version: v24.3.8
  • Server OS: x86_64-pc-linux-gnu
  • Client app: n/a

Additional context
What was the impact?

This makes cutting and pasting the TTL queries for testing more complicated than it needs to be.

Jira issue: CRDB-48614

@elizah18 elizah18 added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Mar 17, 2025
Copy link

blathers-crl bot commented Mar 17, 2025

Hi @elizah18, please add branch-* labels to identify which branch(es) this C-bug affects.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@github-project-automation github-project-automation bot moved this to Triage in SQL Queries Mar 17, 2025
@yuzefovich yuzefovich removed this from SQL Queries Mar 18, 2025
@yuzefovich yuzefovich added the T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) label Mar 18, 2025
@exalate-issue-sync exalate-issue-sync bot added good first issue E-starter Might be suitable for a starter project for new employees or team members. labels Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. E-starter Might be suitable for a starter project for new employees or team members. good first issue T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Projects
None yet
Development

No branches or pull requests

2 participants