question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

varchar(int) columns are reported as text in show create table

See original GitHub issue

Edit:

varchar(int) columns are reported as text in show create table, See https://github.com/crate/crate/issues/10230#issuecomment-659423800

Below is the original issue report:


CrateDB version: 4.1.8

Environment description: CrateDB on Mac

JAVA: 
java version "14.0.1" 2020-04-14
Java(TM) SE Runtime Environment (build 14.0.1+7)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)

KERNEL: 
19.5.0 Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64

The number of nodes: 
1

Configuration by default. 

Problem description:

When I use CREATE TABLE users (id varchar, name varchar(6)); from the documentation: Varchar, I get this error:

SQLActionException[SQLParseException: line 1:45: extraneous input '(' expecting {',', ')'}]

It happens every time I use VARCHAR(INT).

Then, if I change VARCHAR(INT) for TEXT, I get this error:

SQLActionException[SQLParseException: Cannot find data type: varchar]

And when I change VARCHAR for TEXT, I mean, CREATE TABLE users (id TEXT, name TEXT); then it works.

Steps to reproduce:

See Problem Description

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
mfusseneggercommented, Jul 16, 2020

I see you’re right.

The variable is stored as a TEXT, though. Is that the right behavior? CREATE TABLE users (id varchar, name varchar(6)); Table:

Name Type
id TEXT
name TEXT

That’s not good, at least the SHOW CREATE TABLE statement should show the varchar type. It shouldn’t loose information:

create table tbl (name varchar(10));
cr> show create table tbl;
SHOW CREATE TABLE doc.tbl | CREATE TABLE IF NOT EXISTS "doc"."tbl" (
   "name" TEXT
)
CLUSTERED INTO 4 SHARDS
1reaction
MarkusHcommented, Jul 16, 2020

From my understanding, the underlying data types are all the same, and VARCHAR and VARCHAR(int) are only compatibility shims on top. But I’m not sure about that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SQL varchar data type deep dive
We'll review the SQL varchar data type including a basic definition and overview, differences from varchar(n), performance considerations ...
Read more >
SQL Data Types
PointBase supports the following data types for its column and parameter declarations. CHARACTER [(length)] or CHAR [(length)]; VARCHAR (length); BOOLEAN ...
Read more >
Combine varchar column with int column - sql - Stack Overflow
I have two columns in a SQL table, ...
Read more >
SHOW CREATE TABLE - MariaDB Knowledge Base
Shows the CREATE TABLE statement that created the given table. The statement requires the SELECT privilege for the table. This statement also works...
Read more >
13.1.20 CREATE TABLE Statement - MySQL :: Developer Zone
They can be created only from CHAR , VARCHAR , and TEXT columns. ... of the table is reported in the Row_format column...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found