-
Notifications
You must be signed in to change notification settings - Fork 109
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
describe partitions statement #253
Merged
Merged
Changes from 20 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
42965fb
parse DESCRIBE PARTITONS tbl
lauraschlimmer 4912f12
build DescribePartitionsNode
lauraschlimmer 7d45e10
listPartitions wip
lauraschlimmer 1cfcb26
Merge branch 'master' of github.com:eventql/eventql into feature/desc…
lauraschlimmer 7338346
list table partitions
lauraschlimmer c4eb258
Merge branch 'master' of github.com:eventql/eventql into feature/desc…
lauraschlimmer 067d5c8
docu
lauraschlimmer f46e3f9
don't randomize the server list in queries
lauraschlimmer 1e46d6f
fixed test
lauraschlimmer a5308b0
merged master
lauraschlimmer 29acb92
moved TablePartitionInfo to the eventql namespace
lauraschlimmer 769d0d8
CHANGELOG
lauraschlimmer a8db51c
DESCRIBE PARTITIONS docu
lauraschlimmer 937f85a
Merge branch 'master' of github.com:eventql/eventql into feature/desc…
lauraschlimmer 36614e2
better describe partuitions stmt docu
lauraschlimmer 921e6e3
fixed describe partitions result column order
lauraschlimmer f2a0b03
fixed missing keyrange
lauraschlimmer 035a355
marked TableProvider::listPartitions virtual
lauraschlimmer b84d9de
merged master
lauraschlimmer 5fb651b
get PartitionMap and ConfigDirectory from dbctx
lauraschlimmer ce1027e
use StringUtil::join
lauraschlimmer c6f378e
added column extra info
lauraschlimmer 7e53ed2
added column Keyrange end
lauraschlimmer da47014
naming: col -> server
lauraschlimmer 831b82e
Merge branch 'master' of github.com:eventql/eventql into feature/desc…
lauraschlimmer 0cfcc5b
describe partitions example
lauraschlimmer 2b90d27
Merge branch 'master' of github.com:eventql/eventql into feature/desc…
lauraschlimmer 155de44
init metadata client
lauraschlimmer ea75cc5
docu header
lauraschlimmer File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,3 @@ | |
|
||
DESCRIBE table_name | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
5.2.7 DESCRIBE PARTITIONS | ||
=============================== | ||
|
||
DESCRIBE PARTITIONS table_name | ||
|
||
|
||
|
||
DESCRIBE PARTITIONS displays information about all partitions of the table. | ||
|
||
|
||
Example | ||
|
||
evql> DESCRIBE PARTITIONS sensors; | ||
|
||
+------------------------------------------+------------------------+---------------------+ | ||
| Partition id | Keyrange Begin | Servers | | ||
+------------------------------------------+------------------------+---------------------+ | ||
| 48127ec1a9c0812af6ba0240013c99baea40e22e | 2016-02-08 00:00:00 | node1, node3, node4 | | ||
+------------------------------------------+------------------------+---------------------+ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/** | ||
* Copyright (c) 2016 DeepCortex GmbH <legal@eventql.io> | ||
* Authors: | ||
* - Laura Schlimmer <laura@eventql.io> | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under | ||
* the terms of the GNU Affero General Public License ("the license") as | ||
* published by the Free Software Foundation, either version 3 of the License, | ||
* or any later version. | ||
* | ||
* In accordance with Section 7(e) of the license, the licensing of the Program | ||
* under the license does not imply a trademark license. Therefore any rights, | ||
* title and interest in our trademarks remain entirely with us. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the license for more details. | ||
* | ||
* You can be released from the requirements of the license by purchasing a | ||
* commercial license. Buying such a license is mandatory as soon as you develop | ||
* commercial activities involving this program without disclosing the source | ||
* code of your own applications | ||
*/ | ||
#include <eventql/sql/expressions/table/describe_partitions.h> | ||
#include <eventql/sql/transaction.h> | ||
|
||
namespace csql { | ||
|
||
DescribePartitionsExpression::DescribePartitionsExpression( | ||
Transaction* txn, | ||
const String& table_name) : | ||
txn_(txn), | ||
table_name_(table_name), | ||
counter_(0) {} | ||
|
||
ScopedPtr<ResultCursor> DescribePartitionsExpression::execute() { | ||
txn_->getTableProvider()->listPartitions( | ||
table_name_, | ||
[this] (const eventql::TablePartitionInfo& p_info) { | ||
rows_.emplace_back(p_info); | ||
}); | ||
|
||
return mkScoped( | ||
new DefaultResultCursor( | ||
kNumColumns, | ||
std::bind( | ||
&DescribePartitionsExpression::next, | ||
this, | ||
std::placeholders::_1, | ||
std::placeholders::_2))); | ||
|
||
} | ||
|
||
size_t DescribePartitionsExpression::getNumColumns() const { | ||
return kNumColumns; | ||
} | ||
|
||
bool DescribePartitionsExpression::next(SValue* row, size_t row_len) { | ||
if (counter_ < rows_.size()) { | ||
const auto& col = rows_[counter_]; | ||
switch (row_len) { | ||
default: | ||
case 3: { | ||
std::string server_ids; | ||
for (size_t i = 0; i < col.server_ids.size(); ++i) { | ||
if (i > 0) { | ||
server_ids += ", "; | ||
} | ||
server_ids += col.server_ids[i]; | ||
} | ||
row[2] = SValue::newString(server_ids); //Server id | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. StringUtil::join(server_ids, ", ") |
||
} | ||
case 2: | ||
row[1] = SValue::newString(col.keyrange_begin); //Keyrange begin | ||
case 1: | ||
row[0] = SValue::newString(col.partition_id); //Partition id | ||
case 0: | ||
break; | ||
} | ||
|
||
++counter_; | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
} //csql | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* Copyright (c) 2016 DeepCortex GmbH <legal@eventql.io> | ||
* Authors: | ||
* - Laura Schlimmer <laura@eventql.io> | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under | ||
* the terms of the GNU Affero General Public License ("the license") as | ||
* published by the Free Software Foundation, either version 3 of the License, | ||
* or any later version. | ||
* | ||
* In accordance with Section 7(e) of the license, the licensing of the Program | ||
* under the license does not imply a trademark license. Therefore any rights, | ||
* title and interest in our trademarks remain entirely with us. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the license for more details. | ||
* | ||
* You can be released from the requirements of the license by purchasing a | ||
* commercial license. Buying such a license is mandatory as soon as you develop | ||
* commercial activities involving this program without disclosing the source | ||
* code of your own applications | ||
*/ | ||
#pragma once | ||
#include "eventql/eventql.h" | ||
#include <eventql/util/stdtypes.h> | ||
#include <eventql/sql/qtree/ShowTablesNode.h> | ||
#include <eventql/sql/runtime/tablerepository.h> | ||
|
||
namespace csql { | ||
|
||
class DescribePartitionsExpression : public TableExpression { | ||
public: | ||
|
||
static const size_t kNumColumns = 3; | ||
|
||
DescribePartitionsExpression( | ||
Transaction* txn, | ||
const String& table_name); | ||
|
||
ScopedPtr<ResultCursor> execute() override; | ||
|
||
size_t getNumColumns() const override; | ||
|
||
protected: | ||
|
||
bool next(SValue* row, size_t row_len); | ||
|
||
Transaction* txn_; | ||
String table_name_; | ||
Vector<eventql::TablePartitionInfo> rows_; | ||
size_t counter_; | ||
}; | ||
|
||
} //csql | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,7 @@ class Token { | |
T_SHOW, | ||
T_DESCRIBE, | ||
T_EXPLAIN, | ||
T_PARTITIONS, | ||
T_PRIMARY, | ||
T_KEY, | ||
T_REPEATED, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why col, not row?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as the method's first argument is named 'row', I changed 'col' to 'partition'