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

ISSUES-117 support temporary table management #1824

Merged
merged 11 commits into from
Feb 8, 2018

Conversation

zhang2014
Copy link
Contributor

fix #117
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

@zhang2014 zhang2014 changed the title [WIP]ISSUES-117 support temporary table management [WIP] ISSUES-117 support temporary table management Jan 25, 2018
@zhang2014 zhang2014 force-pushed the fix/ISSUES-117 branch 3 times, most recently from b9340f0 to 1070e46 Compare January 27, 2018 16:03
@zhang2014 zhang2014 changed the title [WIP] ISSUES-117 support temporary table management ISSUES-117 support temporary table management Jan 31, 2018
{
if (!name_p.parse(pos, database, expected))
return false;
} else {
Copy link
Contributor

@ludv1x ludv1x Feb 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style:

}
else
{
    ...
}

@@ -30,6 +31,9 @@ static ColumnPtr getFilteredDatabases(const ASTPtr & query, const Context & cont
for (const auto & db : context.getDatabases())
column->insert(db.first);

std::string temporary_database = "";
column->insert(temporary_database);
Copy link
Contributor

@ludv1x ludv1x Feb 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just column->insertDefault() `column->insert(String{})

CREATE TEMPORARY TABLE temp_tab (number UInt64);
INSERT INTO temp_tab SELECT number FROM system.numbers LIMIT 1;
SELECT number FROM temp_tab;
DROP TEMPORARY TABLE temp_tab;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the new syntax backwards-compatible with the previous one?

res_columns[1]->insert(table_name);
res_columns[2]->insert(iterator->table()->getName());
res_columns[3]->insert(static_cast<UInt64>(database->getTableMetadataModificationTime(context, table_name)));
Tables externalTables = context.getSessionContext().getExternalTables();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Camel case (externalTables) is used only for function names.

@@ -30,6 +31,9 @@ static ColumnPtr getFilteredDatabases(const ASTPtr & query, const Context & cont
for (const auto & db : context.getDatabases())
column->insert(db.first);

std::string temporary_database = "";
column->insert(temporary_database);

Block block { ColumnWithTypeAndName( std::move(column), std::make_shared<DataTypeString>(), "database" ) };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also put column temporary into the block.
It allows excluding the temporary database in case of WHERE temporary != 0

@@ -38,6 +38,10 @@ String InterpreterShowTablesQuery::getRewrittenQuery()
*/
context.assertDatabaseExists(database, false);

if (query.temporary) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style

@zhang2014 zhang2014 force-pushed the fix/ISSUES-117 branch 3 times, most recently from 3c4987f to 02afa74 Compare February 2, 2018 13:26
if (s_from.ignore(pos, expected))
{
if (query->temporary)
throw Exception("Unable to parse FROM,Because the temporary table does not have a database.");
Copy link
Contributor

@ludv1x ludv1x Feb 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add an error code?
I would suggest ErrorCodes::SYNTAX_ERROR, but I am not sure it is a syntax error, it is some kind of user error, and the check should be done in the interpreter.

@@ -14,7 +14,7 @@ namespace DB
class ParserShowTablesQuery : public IParserBase
{
protected:
const char * getName() const { return "SHOW TABLES|DATABASES query"; }
const char * getName() const { return "SHOW [TEMPORARY] TABLES|DATABASES query"; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add the full syntax with NOT LIKE ...

{
Tables external_tables = context.getSessionContext().getExternalTables();

for (auto table = external_tables.begin(); table != external_tables.end(); table++)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO it is better to use for-range loop

@zhang2014 zhang2014 force-pushed the fix/ISSUES-117 branch 2 times, most recently from a9d6e66 to 2c3451b Compare February 2, 2018 14:53
@alexey-milovidov alexey-milovidov merged commit d6b7233 into ClickHouse:master Feb 8, 2018
alexey-milovidov added a commit that referenced this pull request Feb 8, 2018
@zhang2014 zhang2014 deleted the fix/ISSUES-117 branch February 14, 2018 04:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Temporary table management
3 participants