-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
CSVREAD can't be used with parameter #2634
Comments
It is not obvious how to parse a CSV file in java, and ensure that the values are recognised/converted to the same types as H2 would do. This feature would be necessary to ensure that a CSV file is parsed exactly the same way as H2 does internally. |
|
Sorry, my misunderstanding. So is it the |
Yes,
command CREATE TABLE TEST AS SELECT * FROM CSVREAD('1.csv'); will create a table with the following definition and content: CREATE TABLE "PUBLIC"."TEST"(
"A" CHARACTER VARYING,
"B" CHARACTER VARYING,
"C" CHARACTER VARYING
);
INSERT INTO "PUBLIC"."TEST" VALUES
('1', 'AAA', '2.5'),
('2', 'BBB', '3.7'); Alternatively you can create a table with column types you need and insert data into it: CREATE TABLE TEST(A BIGINT, B VARCHAR(255), C NUMERIC(5, 1));
INSERT INTO TEST SELECT * FROM CSVREAD('1.csv'); In this case H2 will perform conversions to these data types in the H2 also allows non-standard table definitions with fully declared columns and table subquery: CREATE TABLE TEST(A BIGINT, B VARCHAR(255), C NUMERIC(5, 1)) AS (SELECT * FROM CSVREAD('1.csv')); This definition also performs conversion in the same way as |
The text was updated successfully, but these errors were encountered: