Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit 0969eec

Browse files
authored
Merge branch 'master' into fix/parser_typecast
2 parents 07233bf + df1d952 commit 0969eec

File tree

3 files changed

+125
-23
lines changed

3 files changed

+125
-23
lines changed

script/installation/packages.sh

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,12 @@ function install_protobuf3.4.0() {
6767
# Utility function for installing tensorflow components of python/C++
6868
function install_tf() {
6969
TFCApiFile=$1
70-
TFBinaryURL=$2
70+
TF_VERSION=$2
7171
LinkerConfigCmd=$3
7272
TARGET_DIRECTORY="/usr/local"
7373
# Install Tensorflow Python Binary
74-
sudo -E pip3 install --upgrade ${TFBinaryURL}
74+
sudo -E pip3 install --upgrade pip
75+
sudo -E pip3 install --upgrade tensorflow==${TF_VERSION}
7576

7677
# Install C-API
7778
TFCApiURL="https://storage.googleapis.com/tensorflow/libtensorflow/${TFCApiFile}"
@@ -88,7 +89,6 @@ function install_tf() {
8889
## ------------------------------------------------
8990
if [ "$DISTRO" = "UBUNTU" ]; then
9091
MAJOR_VER=$(echo "$DISTRO_VER" | cut -d '.' -f 1)
91-
9292
# Fix for LLVM-3.7 on Ubuntu 14 + 17
9393
if [ "$MAJOR_VER" == "14" -o "$MAJOR_VER" == "17" ]; then
9494
if [ "$MAJOR_VER" == "14" ]; then
@@ -120,19 +120,16 @@ if [ "$DISTRO" = "UBUNTU" ]; then
120120
if [ "$MAJOR_VER" == "14" ]; then
121121
PKG_CMAKE="cmake3"
122122
FORCE_Y="--force-yes"
123-
TF_VERSION="1.4.0"
124-
TFBinaryURL="https://storage.googleapis.com/tensorflow/linux/${TF_TYPE}/tensorflow-${TF_VERSION}-cp34-cp34m-linux_x86_64.whl"
123+
TF_VERSION="1.4.0"
125124
fi
126125
if [ "$MAJOR_VER" == "16" ]; then
127-
TF_VERSION="1.5.0"
128-
TFBinaryURL="https://storage.googleapis.com/tensorflow/linux/${TF_TYPE}/tensorflow-${TF_VERSION}-cp35-cp35m-linux_x86_64.whl"
126+
TF_VERSION="1.5.0"
129127
fi
130128
# Fix for llvm on Ubuntu 17.x
131129
if [ "$MAJOR_VER" == "17" ]; then
132130
PKG_LLVM="llvm-3.9"
133131
PKG_CLANG="clang-3.8"
134-
TF_VERSION="1.5.0"
135-
TFBinaryURL="https://storage.googleapis.com/tensorflow/linux/${TF_TYPE}/tensorflow-${TF_VERSION}-cp35-cp35m-linux_x86_64.whl"
132+
TF_VERSION="1.5.0"
136133
fi
137134
TFCApiFile="libtensorflow-${TF_TYPE}-linux-x86_64-${TF_VERSION}.tar.gz"
138135
LinkerConfigCmd="sudo ldconfig"
@@ -168,7 +165,7 @@ if [ "$DISTRO" = "UBUNTU" ]; then
168165
# Install version of protobuf needed by C-API
169166
install_protobuf3.4.0 "ubuntu"
170167
# Install tensorflow
171-
install_tf "$TFCApiFile" "$TFBinaryURL" "$LinkerConfigCmd"
168+
install_tf "$TFCApiFile" "$TF_VERSION" "$LinkerConfigCmd"
172169

173170
## ------------------------------------------------
174171
## DEBIAN
@@ -208,7 +205,6 @@ elif [[ "$DISTRO" == *"FEDORA"* ]]; then
208205
esac
209206
TF_VERSION="1.5.0"
210207
TFCApiFile="libtensorflow-${TF_TYPE}-linux-x86_64-${TF_VERSION}.tar.gz"
211-
TFBinaryURL="https://storage.googleapis.com/tensorflow/linux/${TF_TYPE}/tensorflow-${TF_VERSION}-cp36-cp36m-linux_x86_64.whl"
212208
LinkerConfigCmd="sudo ldconfig"
213209
sudo dnf -q install -y \
214210
git \
@@ -244,7 +240,7 @@ elif [[ "$DISTRO" == *"FEDORA"* ]]; then
244240
# Install version of protobuf needed by C-API
245241
install_protobuf3.4.0 "fedora"
246242
# Install tensorflow
247-
install_tf "$TFCApiFile" "$TFBinaryURL" "$LinkerConfigCmd"
243+
install_tf "$TFCApiFile" "$TF_VERSION" "$LinkerConfigCmd"
248244

249245
## ------------------------------------------------
250246
## REDHAT
@@ -325,7 +321,6 @@ elif [ "$DISTRO" = "DARWIN" ]; then
325321
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
326322
fi
327323
TF_VERSION="1.4.0"
328-
TFBinaryURL="https://storage.googleapis.com/tensorflow/mac/${TF_TYPE}/tensorflow-${TF_VERSION}-py3-none-any.whl"
329324
TFCApiFile="libtensorflow-${TF_TYPE}-darwin-x86_64-${TF_VERSION}.tar.gz"
330325
LinkerConfigCmd="sudo update_dyld_shared_cache"
331326
brew install git
@@ -349,7 +344,7 @@ elif [ "$DISTRO" = "DARWIN" ]; then
349344
brew upgrade python
350345
# Brew installs correct version of Protobuf(3.5.1 >= 3.4.0)
351346
# So we can directly install tensorflow
352-
install_tf "$TFCApiFile" "$TFBinaryURL" "$LinkerConfigCmd"
347+
install_tf "$TFCApiFile" "$TF_VERSION" "$LinkerConfigCmd"
353348

354349
## ------------------------------------------------
355350
## UNKNOWN

src/codegen/operator/update_translator.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,14 @@ UpdateTranslator::UpdateTranslator(const planner::UpdatePlan &update_plan,
4141
UpdaterProxy::GetType(GetCodeGen()));
4242
}
4343

44-
bool IsTarget(const TargetList &target_list, uint32_t index) {
45-
for (const auto &target : target_list) {
46-
if (target.first == index) {
47-
return true;
44+
oid_t GetTargetIndex(const TargetList &target_list, uint32_t index) {
45+
oid_t target_size = target_list.size();
46+
for (oid_t i = 0; i < target_size; i++) {
47+
if (target_list[i].first == index) {
48+
return i;
4849
}
4950
}
50-
return false;
51+
return INVALID_OID;
5152
}
5253

5354
void UpdateTranslator::InitializeState() {
@@ -93,13 +94,13 @@ void UpdateTranslator::Consume(ConsumerContext &, RowBatch::Row &row) const {
9394

9495
// Collect all the column values
9596
std::vector<codegen::Value> values;
96-
for (uint32_t i = 0, target_id = 0; i < column_num; i++) {
97+
for (uint32_t i = 0; i < column_num; i++) {
9798
codegen::Value val;
98-
if (IsTarget(target_list, i)) {
99+
uint32_t target_index = GetTargetIndex(target_list, i);
100+
if (target_index != INVALID_OID) {
99101
// Set the value for the update
100-
const auto &derived_attribute = target_list[target_id].second;
102+
const auto &derived_attribute = target_list[target_index].second;
101103
val = row.DeriveValue(codegen, *derived_attribute.expr);
102-
target_id++;
103104
} else {
104105
val = row.DeriveValue(codegen, ais[i]);
105106
}

test/sql/update_sql_test.cpp

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,5 +527,111 @@ TEST_F(UpdateSQLTests, MultiTileGroupUpdateSQLTest) {
527527
txn_manager.CommitTransaction(txn);
528528
}
529529

530+
TEST_F(UpdateSQLTests, AttributeOrderUpdateSQLTest) {
531+
// This test updates the attributes of the table in different orders.
532+
// It ensure that the updates in the data_table are in the correct
533+
// order irrespective of the order of attributes in the update statement.
534+
535+
LOG_DEBUG("Bootstrapping...");
536+
537+
auto catalog = catalog::Catalog::GetInstance();
538+
auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance();
539+
auto txn = txn_manager.BeginTransaction();
540+
catalog->CreateDatabase(DEFAULT_DB_NAME, txn);
541+
txn_manager.CommitTransaction(txn);
542+
543+
LOG_DEBUG("Bootstrapping completed!");
544+
545+
txn = txn_manager.BeginTransaction();
546+
// Create a table first
547+
LOG_DEBUG("Creating a table...");
548+
LOG_DEBUG("Query: CREATE TABLE test(a INT, b INT)");
549+
550+
TestingSQLUtil::ExecuteSQLQuery("CREATE TABLE test(a INT, b INT);");
551+
txn_manager.CommitTransaction(txn);
552+
553+
LOG_DEBUG("Table created!");
554+
555+
txn = txn_manager.BeginTransaction();
556+
// Insert a tuple into table
557+
LOG_DEBUG("Inserting a tuple...");
558+
559+
LOG_DEBUG("Query: INSERT INTO test VALUES (1, 100)");
560+
TestingSQLUtil::ExecuteSQLQuery("INSERT INTO test VALUES (1, 100);");
561+
562+
txn_manager.CommitTransaction(txn);
563+
LOG_DEBUG("Tuple inserted!");
564+
565+
txn = txn_manager.BeginTransaction();
566+
// Update a tuple in the table in the order (b, a)
567+
LOG_DEBUG("Updating a tuple...");
568+
LOG_DEBUG("Query: UPDATE test SET b = b * 2, a = a * 2");
569+
570+
std::vector<ResultValue> result;
571+
std::vector<FieldInfo> tuple_descriptor;
572+
std::string error_message;
573+
int rows_affected;
574+
575+
TestingSQLUtil::ExecuteSQLQuery("UPDATE test SET b = b * 2, a = a * 2;",
576+
result, tuple_descriptor, rows_affected,
577+
error_message);
578+
579+
txn_manager.CommitTransaction(txn);
580+
// Check the return value
581+
EXPECT_EQ(1, rows_affected);
582+
LOG_DEBUG("Tuple Update successful!");
583+
584+
// Check the updated values.
585+
txn = txn_manager.BeginTransaction();
586+
// Update a tuple in the table in the order (b, a)
587+
LOG_DEBUG("Selecting the updated tuple...");
588+
LOG_DEBUG("Query: SELECT a, b FROM test;");
589+
590+
TestingSQLUtil::ExecuteSQLQuery("SELECT a, b FROM test;", result,
591+
tuple_descriptor, rows_affected,
592+
error_message);
593+
594+
txn_manager.CommitTransaction(txn);
595+
// Check the return value
596+
EXPECT_EQ(TestingSQLUtil::GetResultValueAsString(result, 0), "2");
597+
EXPECT_EQ(TestingSQLUtil::GetResultValueAsString(result, 1), "200");
598+
LOG_DEBUG("Attributes updated in the correct order!");
599+
600+
txn = txn_manager.BeginTransaction();
601+
// Update a tuple in the table in the order (a, b)
602+
LOG_DEBUG("Updating a tuple again...");
603+
LOG_DEBUG("Query: UPDATE test SET a = a * 2, b = b * 2");
604+
605+
TestingSQLUtil::ExecuteSQLQuery("UPDATE test SET a = a * 2, b = b * 2;",
606+
result, tuple_descriptor, rows_affected,
607+
error_message);
608+
609+
txn_manager.CommitTransaction(txn);
610+
// Check the return value
611+
EXPECT_EQ(1, rows_affected);
612+
LOG_DEBUG("Tuple Update successful, agin!");
613+
614+
// Check the updated values.
615+
txn = txn_manager.BeginTransaction();
616+
// Update a tuple in the table in the order (b, a)
617+
LOG_DEBUG("Selecting the updated tuple...");
618+
LOG_DEBUG("Query: SELECT a, b FROM test;");
619+
620+
TestingSQLUtil::ExecuteSQLQuery("SELECT a, b FROM test;", result,
621+
tuple_descriptor, rows_affected,
622+
error_message);
623+
624+
txn_manager.CommitTransaction(txn);
625+
// Check the return value
626+
EXPECT_EQ(TestingSQLUtil::GetResultValueAsString(result, 0), "4");
627+
EXPECT_EQ(TestingSQLUtil::GetResultValueAsString(result, 1), "400");
628+
LOG_DEBUG("Attributes updated in the correct order, again!");
629+
630+
// free the database just created
631+
txn = txn_manager.BeginTransaction();
632+
catalog::Catalog::GetInstance()->DropDatabaseWithName(DEFAULT_DB_NAME, txn);
633+
txn_manager.CommitTransaction(txn);
634+
}
635+
530636
} // namespace test
531637
} // namespace peloton

0 commit comments

Comments
 (0)