Skip to content

Generalized partitioning code 2 - #1235

Merged
alexey-milovidov merged 17 commits into
masterfrom
arbitrary-partitioning
Sep 26, 2017
Merged

alexey-milovidov merged 17 commits into
masterfrom
arbitrary-partitioning

Conversation

@ztlpn

@ztlpn ztlpn commented Sep 12, 2017

Copy link
Copy Markdown
Contributor
  • Version MergeTree data format
  • Allow arbitrary partition literals in ALTER PARTITION queries
  • Add experimental syntax for custom partitioning (for testing purposes)

Comment thread dbms/src/Columns/ColumnArray.cpp Outdated
{
if (compareAt(i, min_idx, *this, /* nan_direction_hint = */ 1) < 0)
min_idx = i;
if (compareAt(i, max_idx, *this, /* nan_direction_hint = */ -1) > 0)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

else if?

result += toString(DateLUT::instance().toNumYYYYMMDD(DayNum_t(value[i].get<UInt64>())));
else
result += applyVisitor(to_string_visitor, value[i]);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I assume that you had the same thoughts while writing this code:
"we cannot do the same for DateTime because it will depend on timezones".

Better to write it in comment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually no, I was just lazy :) Good point.

: partition_lit->value.safeGet<String>();
}
else
prefix = getPartitionIDFromQuery(partition_ast, context);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Possibly unintended behavior if you have numeric partition key and partitions

1
11
111

(that have common prefix)

@ztlpn ztlpn Sep 13, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am unsure if this is needed (in case of custom partitioning we can forbid prefixes and allow only exact matches), though when partitioning is by date it will be handy. Proper way is of course to implement some form of ALTER PARTITION WHERE.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

On the second thought I am inclined to forbid it in case of custom partitioning. Because otherwise a user will be unable to freeze only partition '1' without also freezing partition '11'.


STRONG_TYPEDEF(UInt32, MergeTreeDataFormatVersion);

const MergeTreeDataFormatVersion MERGE_TREE_DATA_MIN_FORMAT_VERSION_WITH_CUSTOM_PARTITIONING {1};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It can fail at link time if we ever take an address of this constant (example: debug build and passing it to std::max).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Global constants should be OK (they have internal linkage by default). The problem may be with static const class members, but it is not the case here.

@alexey-milovidov
alexey-milovidov merged commit 6e57272 into master Sep 26, 2017
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.

2 participants