-
Notifications
You must be signed in to change notification settings - Fork 619
Namespace(Schema) support + Catalog refactoring #1302
Conversation
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.
Hey @mengranwo, @camellyx!
Nice job! I think this PR looks good. I just had a few questions (mostly present in the review).
- Why is there a change the visibility of the catalog contractors (eg.
ColumnCatalog
,IndexCatalog
, etc)? - Can you please add
CATALOG_TABLES_COUNT
or something similar in thecatalog_defaults.h
. And make sure the test cases check equality of this number instead of8
. - Would it be possible to remove the
Bootstrap
calls from the first test to the constructor in thePelotonTest
class? We seem to be calling it in most functions or you can derive aCatalogTestUtil
class and have this done inside it. - Why did most of the SQL tests require explicitly appending the
public
schema to the query. The binder should be taking care of it right? - Can you add a test which creates two tables with the same name in two different schemas? Also another test which lets a query select from two tables in two different schemas?
- Does this PR include support for
TempSchema
? If not, could you write up an issue about it? I think it can be given to a beginner.
test/udf/udf_test.cpp
Outdated
@@ -137,7 +136,7 @@ TEST_F(UDFTest, IfElseExpressionTest) { | |||
auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); | |||
auto txn = txn_manager.BeginTransaction(); | |||
catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); | |||
catalog::Catalog::GetInstance()->Bootstrap(); | |||
// catalog::Catalog::GetInstance()->Bootstrap(); |
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.
Since this line is commented out, please delete it.
test/udf/udf_test.cpp
Outdated
@@ -196,7 +195,7 @@ TEST_F(UDFTest, RecursiveFunctionTest) { | |||
auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance(); | |||
auto txn = txn_manager.BeginTransaction(); | |||
catalog::Catalog::GetInstance()->CreateDatabase(DEFAULT_DB_NAME, txn); | |||
catalog::Catalog::GetInstance()->Bootstrap(); | |||
// catalog::Catalog::GetInstance()->Bootstrap(); |
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.
Since this line is commented out, please delete it.
test/trigger/trigger_test.cpp
Outdated
catalog::Catalog::GetInstance()->Bootstrap(); | ||
// NOTE: Catalog::GetInstance()->Bootstrap() has been called in previous tests | ||
// you can only call it once! | ||
// catalog::Catalog::GetInstance()->Bootstrap(); |
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.
Since this line is commented out, please delete it.
test/trigger/trigger_test.cpp
Outdated
catalog::Catalog::GetInstance()->Bootstrap(); | ||
// NOTE: Catalog::GetInstance()->Bootstrap() has been called in previous tests | ||
// you can only call it once! | ||
// catalog::Catalog::GetInstance()->Bootstrap(); |
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.
Since this line is commented out, please delete it.
test/trigger/trigger_test.cpp
Outdated
catalog::Catalog::GetInstance()->Bootstrap(); | ||
// NOTE: Catalog::GetInstance()->Bootstrap() has been called in previous tests | ||
// you can only call it once! | ||
// catalog::Catalog::GetInstance()->Bootstrap(); |
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.
Since this line is commented out, please delete it.
static ColumnCatalog *GetInstance(storage::Database *pg_catalog = nullptr, | ||
type::AbstractPool *pool = nullptr, | ||
concurrency::TransactionContext *txn = nullptr); | ||
ColumnCatalog(storage::Database *pg_catalog, type::AbstractPool *pool, |
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.
Similar to other classes. Why are we making this public?
src/include/catalog/column_catalog.h
Outdated
@@ -83,10 +81,11 @@ class ColumnCatalog : public AbstractCatalog { | |||
// write Related API | |||
//===--------------------------------------------------------------------===// | |||
bool InsertColumn(oid_t table_oid, const std::string &column_name, | |||
oid_t column_id, oid_t column_offset, | |||
uint32_t column_id, uint32_t column_offset, |
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.
Please revert. internal_types.h
typedefs uint32_t
to oid_t
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.
Done!
src/catalog/abstract_catalog.cpp
Outdated
std::vector<oid_t> key_column_offsets = | ||
index->GetMetadata()->GetKeySchema()->GetIndexedColumns(); | ||
PELOTON_ASSERT(scan_values.size() == key_column_offsets.size()); | ||
std::vector<ExpressionType> expr_types(scan_values.size(), |
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.
Since we only allow equal keys, can you please add a line in the documentation? So the next person using it would know.
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.
Done!
src/catalog/catalog.cpp
Outdated
* The system catalog tables must be created in certain order to make sure | ||
* all tuples are indexed (actually this might be fine now after Paulo's fix) | ||
*/ | ||
void Catalog::BootstrapSystemCatalogs(storage::Database *database, |
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.
Please add java doc style documentation for this function.
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.
Done!
src/catalog/table_catalog.cpp
Outdated
@@ -541,5 +561,29 @@ TableCatalog::GetTableObjects(oid_t database_oid, | |||
return database_object->GetTableObjects(); | |||
} | |||
|
|||
bool TableCatalog::UpdateVersionId(oid_t update_val, oid_t table_oid, |
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.
Can you please add java doc style documentation for this function?
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.
Done!
Hey @poojanilangekar!
|
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.
Thanks @mengranwo for addressing all the comments.
LGTM!
@tcm-marcel, The same issue again. Travis build is not triggered. Do you think the bug is because of some error in our configuration or a bug on their end? |
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.
@camellyx Thanks for adding the test!
Overall this PR is ready to be merged in!
If you or @mengranwo can resolve the merge conflicts and address minor issues in the review, I think we can merge this today or tomorrow. Thanks!
test/catalog/catalog_test.cpp
Outdated
@@ -116,40 +117,6 @@ TEST_F(CatalogTests, CreatingTable) { | |||
->GetColumnObject(1) | |||
->GetColumnName()); | |||
txn_manager.CommitTransaction(txn); | |||
// EXPECT_EQ(5, time_stamp); |
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.
Would it be possible for you to check the table count? Currently it should be 8, correct? Similarly to the index as well?
So this way we can check that people always account for the additional catalog tables/indexes they create.
test/sql/testing_sql_util.cpp
Outdated
@@ -248,7 +249,9 @@ void TestingSQLUtil::ExecuteSQLQueryAndCheckResult( | |||
// Execute query | |||
TestingSQLUtil::ExecuteSQLQuery(std::move(query), result, tuple_descriptor, | |||
rows_changed, error_message); | |||
unsigned int rows = result.size() / tuple_descriptor.size(); | |||
unsigned int rows = tuple_descriptor.size() == 0 |
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.
Should we add a PELOTON_ASSERT
instead? I mean, ideally we should only have an emptyresult
if the tuple_descriptor.size()
is 0, right? Or am I missing a corner case?
@@ -23,6 +23,8 @@ | |||
#include "executor/update_executor.h" | |||
#include "expression/abstract_expression.h" | |||
#include "expression/operator_expression.h" | |||
|
|||
#define private public |
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.
Please change this as well.
@poojanilangekar Thanks for your comments. We are working on adding more tests, if possible, once we have time. |
@poojanilangekar I think we are ready to go. |
Thanks @mengranwo! |
* codegen insert catalog tuple * fix segfault caused by bad insert plan * consider cached catalog queries * add update method using old engine * add update method using old engine * add version id column into pg_table * column id and offset use uint32 * system catalogs * using system catalog instead of singleton * remove default constructer * fix catalog map * system catalog return value change to shared pointer * refactoring system catalog, seems to compile now * refactor fix * refactor, peloton can start and finish bootstrap. TODO: refactor global unique oid * fixed pg_database index, still cannot find system catalog in other databases * fix two misuse of CATALOG_DATABASE_OID * seems to work now * fix two tests * fix drop index bug, need information about database * change test case, mainly gettablecount * fix query cache test * half way fixing trigger test * trigger catalog * move trigger_catalog into per database * can pass trigger test now, also drop trigger when drop table * fix udf test, bootstrap only once * fix db names * initialize nullptr * TODO: fix GetInstance, fix AddBuiltInFunctions * roll back pg_proc for now... require refactoring later * query metrics catalog refactor * change metrics tables access method * stats_test still has problem * fix query metrics bugs, pass test cases in stats_test * merge local changes * fix all the test cases * fix double initialize * add full functionality of create/drop schema(namespace) * rebase to latest master branch * add more comments * fix test case errors, able to compile, one failing test * resolve conflicts * fix iso compile bug * make changes according to pooja's reviews * added namespace sql test * addressing pooja's comments * fix plan util test
@mengranwo I think there are typos in src/include/catalog/catalog_defaults.h and other places. |
* codegen insert catalog tuple * fix segfault caused by bad insert plan * consider cached catalog queries * add update method using old engine * add update method using old engine * add version id column into pg_table * column id and offset use uint32 * system catalogs * using system catalog instead of singleton * remove default constructer * fix catalog map * system catalog return value change to shared pointer * refactoring system catalog, seems to compile now * refactor fix * refactor, peloton can start and finish bootstrap. TODO: refactor global unique oid * fixed pg_database index, still cannot find system catalog in other databases * fix two misuse of CATALOG_DATABASE_OID * seems to work now * fix two tests * fix drop index bug, need information about database * change test case, mainly gettablecount * fix query cache test * half way fixing trigger test * trigger catalog * move trigger_catalog into per database * can pass trigger test now, also drop trigger when drop table * fix udf test, bootstrap only once * fix db names * initialize nullptr * TODO: fix GetInstance, fix AddBuiltInFunctions * roll back pg_proc for now... require refactoring later * query metrics catalog refactor * change metrics tables access method * stats_test still has problem * fix query metrics bugs, pass test cases in stats_test * merge local changes * fix all the test cases * fix double initialize * add full functionality of create/drop schema(namespace) * rebase to latest master branch * add more comments * fix test case errors, able to compile, one failing test * resolve conflicts * fix iso compile bug * make changes according to pooja's reviews * added namespace sql test * addressing pooja's comments * fix plan util test
1. catalog refactoring
2. Namespace(Schema) support
3. To-Do
Fix test cases (consult with PR [15721] Temporary Table #1286)