diff --git a/docs/en/sql-reference/statements/create/table.md b/docs/en/sql-reference/statements/create/table.md index d09ff24efcd..c20981b6bbf 100644 --- a/docs/en/sql-reference/statements/create/table.md +++ b/docs/en/sql-reference/statements/create/table.md @@ -254,7 +254,6 @@ CREATE TABLE codec_example ENGINE = MergeTree() ``` - + ## Temporary Tables {#temporary-tables} ClickHouse supports temporary tables which have the following characteristics: diff --git a/programs/client/Client.cpp b/programs/client/Client.cpp index 65e245750b3..ca7fd98b77e 100644 --- a/programs/client/Client.cpp +++ b/programs/client/Client.cpp @@ -62,6 +62,7 @@ #include #include #include +#include #include #include #include diff --git a/src/Parsers/ParserInsertQuery.cpp b/src/Parsers/ParserInsertQuery.cpp index 19457f027bf..8f577288e65 100644 --- a/src/Parsers/ParserInsertQuery.cpp +++ b/src/Parsers/ParserInsertQuery.cpp @@ -111,6 +111,11 @@ bool ParserInsertQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected) { data = pos->begin; } + else if (s_from_infile.ignore(pos, expected)) + { + if (!infile_name_p.parse(pos, infile, expected)) + return false; + } else if (s_format.ignore(pos, expected)) { if (!name_p.parse(pos, format, expected)) diff --git a/tests/queries/0_stateless/02009_from_infile.sh b/tests/queries/0_stateless/02009_from_infile.sh index 578ac14f558..fa3664eb0f8 100755 --- a/tests/queries/0_stateless/02009_from_infile.sh +++ b/tests/queries/0_stateless/02009_from_infile.sh @@ -9,12 +9,14 @@ set -e [ -e "${CLICKHOUSE_TMP}"/test_infile.gz ] && rm "${CLICKHOUSE_TMP}"/test_infile.gz [ -e "${CLICKHOUSE_TMP}"/test_infile ] && rm "${CLICKHOUSE_TMP}"/test_infile + echo "Hello" > "${CLICKHOUSE_TMP}"/test_infile gzip "${CLICKHOUSE_TMP}"/test_infile ${CLICKHOUSE_CLIENT} --query "DROP TABLE IF EXISTS test_infile;" ${CLICKHOUSE_CLIENT} --query "CREATE TABLE test_infile (word String) ENGINE=Memory();" + ${CLICKHOUSE_CLIENT} --query "INSERT INTO test_infile FROM INFILE '${CLICKHOUSE_TMP}/test_infile.gz' FORMAT CSV;" ${CLICKHOUSE_CLIENT} --query "SELECT * FROM test_infile;" @@ -26,3 +28,4 @@ ${CLICKHOUSE_CURL} -sS "${CLICKHOUSE_URL}&query=CREATE" -d 'TABLE test_infile_ur ${CLICKHOUSE_CURL} -sS "${CLICKHOUSE_URL}" -d "INSERT INTO test_infile_url FROM INFILE '${CLICKHOUSE_TMP}/test_infile.gz' FORMAT CSV" 2>&1 | grep -q "UNKNOWN_TYPE_OF_QUERY" && echo "Correct URL" || echo 'Fail' ${CLICKHOUSE_CURL} -sS "${CLICKHOUSE_URL}" -d 'SELECT x FROM test_infile_url' ${CLICKHOUSE_CURL} -sS "${CLICKHOUSE_URL}&query=DROP+TABLE" -d 'test_infile_url' + diff --git a/tests/queries/0_stateless/test_infile.gz b/tests/queries/0_stateless/test_infile.gz new file mode 100644 index 00000000000..feb3ac52068 Binary files /dev/null and b/tests/queries/0_stateless/test_infile.gz differ