This is an automated email from the ASF dual-hosted git repository. hmaduri pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/drill.git
commit 814e9f099bf917c22a91a0a8f36d6afef3eac37f Author: Arina Ielchiieva <[email protected]> AuthorDate: Wed Jan 2 20:05:12 2019 +0200 DRILL-6946: Implement java.sql.Connection setSchema and getSchema methods in DrillConnectionImpl closes #1596 --- contrib/native/client/src/protobuf/User.pb.cc | 196 ++++++++---- contrib/native/client/src/protobuf/User.pb.h | 87 +++++- .../exec/work/metadata/ServerMetaProvider.java | 3 +- .../exec/work/metadata/TestServerMetaProvider.java | 43 ++- .../drill/jdbc/impl/DrillConnectionImpl.java | 31 ++ .../org/apache/drill/jdbc/ConnectionInfoTest.java | 85 ++++-- .../apache/drill/exec/proto/SchemaUserProtos.java | 7 + .../org/apache/drill/exec/proto/UserProtos.java | 336 +++++++++++++++++---- .../apache/drill/exec/proto/beans/ServerMeta.java | 22 ++ protocol/src/main/protobuf/User.proto | 2 + 10 files changed, 634 insertions(+), 178 deletions(-) diff --git a/contrib/native/client/src/protobuf/User.pb.cc b/contrib/native/client/src/protobuf/User.pb.cc index e2ae3d1..a0e2acd 100644 --- a/contrib/native/client/src/protobuf/User.pb.cc +++ b/contrib/native/client/src/protobuf/User.pb.cc @@ -671,7 +671,7 @@ void protobuf_AssignDesc_User_2eproto() { ::google::protobuf::MessageFactory::generated_factory(), sizeof(GetServerMetaResp)); ServerMeta_descriptor_ = file->message_type(29); - static const int ServerMeta_offsets_[49] = { + static const int ServerMeta_offsets_[50] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServerMeta, all_tables_selectable_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServerMeta, blob_included_in_max_row_size_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServerMeta, catalog_at_start_), @@ -721,6 +721,7 @@ void protobuf_AssignDesc_User_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServerMeta, table_term_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServerMeta, transaction_supported_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServerMeta, union_support_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServerMeta, current_schema_), }; ServerMeta_reflection_ = new ::google::protobuf::internal::GeneratedMessageReflection( @@ -1039,7 +1040,7 @@ void protobuf_AddDesc_User_2eproto() { "verMetaResp\022(\n\006status\030\001 \001(\0162\030.exec.user." "RequestStatus\022*\n\013server_meta\030\002 \001(\0132\025.exe" "c.user.ServerMeta\022(\n\005error\030\003 \001(\0132\031.exec." - "shared.DrillPBError\"\377\r\n\nServerMeta\022\035\n\025al" + "shared.DrillPBError\"\227\016\n\nServerMeta\022\035\n\025al" "l_tables_selectable\030\001 \001(\010\022%\n\035blob_includ" "ed_in_max_row_size\030\002 \001(\010\022\030\n\020catalog_at_s" "tart\030\003 \001(\010\022\031\n\021catalog_separator\030\004 \001(\t\022\024\n" @@ -1084,70 +1085,70 @@ void protobuf_AddDesc_User_2eproto() { "ySupport\022\030\n\020system_functions\030. \003(\t\022\022\n\nta" "ble_term\030/ \001(\t\022\035\n\025transaction_supported\030" "0 \001(\010\022.\n\runion_support\0301 \003(\0162\027.exec.user" - ".UnionSupport\"\353\001\n\010RunQuery\0221\n\014results_mo" - "de\030\001 \001(\0162\033.exec.user.QueryResultsMode\022$\n" - "\004type\030\002 \001(\0162\026.exec.shared.QueryType\022\014\n\004p" - "lan\030\003 \001(\t\0221\n\tfragments\030\004 \003(\0132\036.exec.bit." - "control.PlanFragment\022E\n\031prepared_stateme" - "nt_handle\030\005 \001(\0132\".exec.user.PreparedStat" - "ementHandle*\320\003\n\007RpcType\022\r\n\tHANDSHAKE\020\000\022\007" - "\n\003ACK\020\001\022\013\n\007GOODBYE\020\002\022\r\n\tRUN_QUERY\020\003\022\020\n\014C" - "ANCEL_QUERY\020\004\022\023\n\017REQUEST_RESULTS\020\005\022\027\n\023RE" - "SUME_PAUSED_QUERY\020\013\022\034\n\030GET_QUERY_PLAN_FR" - "AGMENTS\020\014\022\020\n\014GET_CATALOGS\020\016\022\017\n\013GET_SCHEM" - "AS\020\017\022\016\n\nGET_TABLES\020\020\022\017\n\013GET_COLUMNS\020\021\022\035\n" - "\031CREATE_PREPARED_STATEMENT\020\026\022\023\n\017GET_SERV" - "ER_META\020\010\022\016\n\nQUERY_DATA\020\006\022\020\n\014QUERY_HANDL" - "E\020\007\022\030\n\024QUERY_PLAN_FRAGMENTS\020\r\022\014\n\010CATALOG" - "S\020\022\022\013\n\007SCHEMAS\020\023\022\n\n\006TABLES\020\024\022\013\n\007COLUMNS\020" - "\025\022\026\n\022PREPARED_STATEMENT\020\027\022\017\n\013SERVER_META" - "\020\t\022\020\n\014QUERY_RESULT\020\n\022\020\n\014SASL_MESSAGE\020\030*H" - "\n\013SaslSupport\022\030\n\024UNKNOWN_SASL_SUPPORT\020\000\022" - "\r\n\tSASL_AUTH\020\001\022\020\n\014SASL_PRIVACY\020\002*#\n\020Quer" - "yResultsMode\022\017\n\013STREAM_FULL\020\001*q\n\017Handsha" - "keStatus\022\013\n\007SUCCESS\020\001\022\030\n\024RPC_VERSION_MIS" - "MATCH\020\002\022\017\n\013AUTH_FAILED\020\003\022\023\n\017UNKNOWN_FAIL" - "URE\020\004\022\021\n\rAUTH_REQUIRED\020\005*D\n\rRequestStatu" - "s\022\022\n\016UNKNOWN_STATUS\020\000\022\006\n\002OK\020\001\022\n\n\006FAILED\020" - "\002\022\013\n\007TIMEOUT\020\003*Y\n\023ColumnSearchability\022\031\n" - "\025UNKNOWN_SEARCHABILITY\020\000\022\010\n\004NONE\020\001\022\010\n\004CH" - "AR\020\002\022\n\n\006NUMBER\020\003\022\007\n\003ALL\020\004*K\n\022ColumnUpdat" - "ability\022\030\n\024UNKNOWN_UPDATABILITY\020\000\022\r\n\tREA" - "D_ONLY\020\001\022\014\n\010WRITABLE\020\002*1\n\016CollateSupport" - "\022\016\n\nCS_UNKNOWN\020\000\022\017\n\013CS_GROUP_BY\020\001*J\n\027Cor" - "relationNamesSupport\022\013\n\007CN_NONE\020\001\022\026\n\022CN_" - "DIFFERENT_NAMES\020\002\022\n\n\006CN_ANY\020\003*\271\003\n\027DateTi" - "meLiteralsSupport\022\016\n\nDL_UNKNOWN\020\000\022\013\n\007DL_" - "DATE\020\001\022\013\n\007DL_TIME\020\002\022\020\n\014DL_TIMESTAMP\020\003\022\024\n" - "\020DL_INTERVAL_YEAR\020\004\022\025\n\021DL_INTERVAL_MONTH" - "\020\005\022\023\n\017DL_INTERVAL_DAY\020\006\022\024\n\020DL_INTERVAL_H" - "OUR\020\007\022\026\n\022DL_INTERVAL_MINUTE\020\010\022\026\n\022DL_INTE" - "RVAL_SECOND\020\t\022\035\n\031DL_INTERVAL_YEAR_TO_MON" - "TH\020\n\022\033\n\027DL_INTERVAL_DAY_TO_HOUR\020\013\022\035\n\031DL_" - "INTERVAL_DAY_TO_MINUTE\020\014\022\035\n\031DL_INTERVAL_" - "DAY_TO_SECOND\020\r\022\036\n\032DL_INTERVAL_HOUR_TO_M" - "INUTE\020\016\022\036\n\032DL_INTERVAL_HOUR_TO_SECOND\020\017\022" - " \n\034DL_INTERVAL_MINUTE_TO_SECOND\020\020*Y\n\016Gro" - "upBySupport\022\013\n\007GB_NONE\020\001\022\022\n\016GB_SELECT_ON" - "LY\020\002\022\024\n\020GB_BEYOND_SELECT\020\003\022\020\n\014GB_UNRELAT" - "ED\020\004*x\n\020IdentifierCasing\022\016\n\nIC_UNKNOWN\020\000" - "\022\023\n\017IC_STORES_LOWER\020\001\022\023\n\017IC_STORES_MIXED" - "\020\002\022\023\n\017IC_STORES_UPPER\020\003\022\025\n\021IC_SUPPORTS_M" - "IXED\020\004*X\n\rNullCollation\022\016\n\nNC_UNKNOWN\020\000\022" - "\017\n\013NC_AT_START\020\001\022\r\n\tNC_AT_END\020\002\022\013\n\007NC_HI" - "GH\020\003\022\n\n\006NC_LOW\020\004*E\n\016OrderBySupport\022\016\n\nOB" - "_UNKNOWN\020\000\022\020\n\014OB_UNRELATED\020\001\022\021\n\rOB_EXPRE" - "SSION\020\002*\226\001\n\020OuterJoinSupport\022\016\n\nOJ_UNKNO" - "WN\020\000\022\013\n\007OJ_LEFT\020\001\022\014\n\010OJ_RIGHT\020\002\022\013\n\007OJ_FU" - "LL\020\003\022\r\n\tOJ_NESTED\020\004\022\022\n\016OJ_NOT_ORDERED\020\005\022" - "\014\n\010OJ_INNER\020\006\022\031\n\025OJ_ALL_COMPARISON_OPS\020\007" - "*\204\001\n\017SubQuerySupport\022\016\n\nSQ_UNKNOWN\020\000\022\021\n\r" - "SQ_CORRELATED\020\001\022\024\n\020SQ_IN_COMPARISON\020\002\022\020\n" - "\014SQ_IN_EXISTS\020\003\022\020\n\014SQ_IN_INSERT\020\004\022\024\n\020SQ_" - "IN_QUANTIFIED\020\005*;\n\014UnionSupport\022\r\n\tU_UNK" - "NOWN\020\000\022\013\n\007U_UNION\020\001\022\017\n\013U_UNION_ALL\020\002B+\n\033" - "org.apache.drill.exec.protoB\nUserProtosH" - "\001", 8881); + ".UnionSupport\022\026\n\016current_schema\0302 \001(\t\"\353\001" + "\n\010RunQuery\0221\n\014results_mode\030\001 \001(\0162\033.exec." + "user.QueryResultsMode\022$\n\004type\030\002 \001(\0162\026.ex" + "ec.shared.QueryType\022\014\n\004plan\030\003 \001(\t\0221\n\tfra" + "gments\030\004 \003(\0132\036.exec.bit.control.PlanFrag" + "ment\022E\n\031prepared_statement_handle\030\005 \001(\0132" + "\".exec.user.PreparedStatementHandle*\320\003\n\007" + "RpcType\022\r\n\tHANDSHAKE\020\000\022\007\n\003ACK\020\001\022\013\n\007GOODB" + "YE\020\002\022\r\n\tRUN_QUERY\020\003\022\020\n\014CANCEL_QUERY\020\004\022\023\n" + "\017REQUEST_RESULTS\020\005\022\027\n\023RESUME_PAUSED_QUER" + "Y\020\013\022\034\n\030GET_QUERY_PLAN_FRAGMENTS\020\014\022\020\n\014GET" + "_CATALOGS\020\016\022\017\n\013GET_SCHEMAS\020\017\022\016\n\nGET_TABL" + "ES\020\020\022\017\n\013GET_COLUMNS\020\021\022\035\n\031CREATE_PREPARED" + "_STATEMENT\020\026\022\023\n\017GET_SERVER_META\020\010\022\016\n\nQUE" + "RY_DATA\020\006\022\020\n\014QUERY_HANDLE\020\007\022\030\n\024QUERY_PLA" + "N_FRAGMENTS\020\r\022\014\n\010CATALOGS\020\022\022\013\n\007SCHEMAS\020\023" + "\022\n\n\006TABLES\020\024\022\013\n\007COLUMNS\020\025\022\026\n\022PREPARED_ST" + "ATEMENT\020\027\022\017\n\013SERVER_META\020\t\022\020\n\014QUERY_RESU" + "LT\020\n\022\020\n\014SASL_MESSAGE\020\030*H\n\013SaslSupport\022\030\n" + "\024UNKNOWN_SASL_SUPPORT\020\000\022\r\n\tSASL_AUTH\020\001\022\020" + "\n\014SASL_PRIVACY\020\002*#\n\020QueryResultsMode\022\017\n\013" + "STREAM_FULL\020\001*q\n\017HandshakeStatus\022\013\n\007SUCC" + "ESS\020\001\022\030\n\024RPC_VERSION_MISMATCH\020\002\022\017\n\013AUTH_" + "FAILED\020\003\022\023\n\017UNKNOWN_FAILURE\020\004\022\021\n\rAUTH_RE" + "QUIRED\020\005*D\n\rRequestStatus\022\022\n\016UNKNOWN_STA" + "TUS\020\000\022\006\n\002OK\020\001\022\n\n\006FAILED\020\002\022\013\n\007TIMEOUT\020\003*Y" + "\n\023ColumnSearchability\022\031\n\025UNKNOWN_SEARCHA" + "BILITY\020\000\022\010\n\004NONE\020\001\022\010\n\004CHAR\020\002\022\n\n\006NUMBER\020\003" + "\022\007\n\003ALL\020\004*K\n\022ColumnUpdatability\022\030\n\024UNKNO" + "WN_UPDATABILITY\020\000\022\r\n\tREAD_ONLY\020\001\022\014\n\010WRIT" + "ABLE\020\002*1\n\016CollateSupport\022\016\n\nCS_UNKNOWN\020\000" + "\022\017\n\013CS_GROUP_BY\020\001*J\n\027CorrelationNamesSup" + "port\022\013\n\007CN_NONE\020\001\022\026\n\022CN_DIFFERENT_NAMES\020" + "\002\022\n\n\006CN_ANY\020\003*\271\003\n\027DateTimeLiteralsSuppor" + "t\022\016\n\nDL_UNKNOWN\020\000\022\013\n\007DL_DATE\020\001\022\013\n\007DL_TIM" + "E\020\002\022\020\n\014DL_TIMESTAMP\020\003\022\024\n\020DL_INTERVAL_YEA" + "R\020\004\022\025\n\021DL_INTERVAL_MONTH\020\005\022\023\n\017DL_INTERVA" + "L_DAY\020\006\022\024\n\020DL_INTERVAL_HOUR\020\007\022\026\n\022DL_INTE" + "RVAL_MINUTE\020\010\022\026\n\022DL_INTERVAL_SECOND\020\t\022\035\n" + "\031DL_INTERVAL_YEAR_TO_MONTH\020\n\022\033\n\027DL_INTER" + "VAL_DAY_TO_HOUR\020\013\022\035\n\031DL_INTERVAL_DAY_TO_" + "MINUTE\020\014\022\035\n\031DL_INTERVAL_DAY_TO_SECOND\020\r\022" + "\036\n\032DL_INTERVAL_HOUR_TO_MINUTE\020\016\022\036\n\032DL_IN" + "TERVAL_HOUR_TO_SECOND\020\017\022 \n\034DL_INTERVAL_M" + "INUTE_TO_SECOND\020\020*Y\n\016GroupBySupport\022\013\n\007G" + "B_NONE\020\001\022\022\n\016GB_SELECT_ONLY\020\002\022\024\n\020GB_BEYON" + "D_SELECT\020\003\022\020\n\014GB_UNRELATED\020\004*x\n\020Identifi" + "erCasing\022\016\n\nIC_UNKNOWN\020\000\022\023\n\017IC_STORES_LO" + "WER\020\001\022\023\n\017IC_STORES_MIXED\020\002\022\023\n\017IC_STORES_" + "UPPER\020\003\022\025\n\021IC_SUPPORTS_MIXED\020\004*X\n\rNullCo" + "llation\022\016\n\nNC_UNKNOWN\020\000\022\017\n\013NC_AT_START\020\001" + "\022\r\n\tNC_AT_END\020\002\022\013\n\007NC_HIGH\020\003\022\n\n\006NC_LOW\020\004" + "*E\n\016OrderBySupport\022\016\n\nOB_UNKNOWN\020\000\022\020\n\014OB" + "_UNRELATED\020\001\022\021\n\rOB_EXPRESSION\020\002*\226\001\n\020Oute" + "rJoinSupport\022\016\n\nOJ_UNKNOWN\020\000\022\013\n\007OJ_LEFT\020" + "\001\022\014\n\010OJ_RIGHT\020\002\022\013\n\007OJ_FULL\020\003\022\r\n\tOJ_NESTE" + "D\020\004\022\022\n\016OJ_NOT_ORDERED\020\005\022\014\n\010OJ_INNER\020\006\022\031\n" + "\025OJ_ALL_COMPARISON_OPS\020\007*\204\001\n\017SubQuerySup" + "port\022\016\n\nSQ_UNKNOWN\020\000\022\021\n\rSQ_CORRELATED\020\001\022" + "\024\n\020SQ_IN_COMPARISON\020\002\022\020\n\014SQ_IN_EXISTS\020\003\022" + "\020\n\014SQ_IN_INSERT\020\004\022\024\n\020SQ_IN_QUANTIFIED\020\005*" + ";\n\014UnionSupport\022\r\n\tU_UNKNOWN\020\000\022\013\n\007U_UNIO" + "N\020\001\022\017\n\013U_UNION_ALL\020\002B+\n\033org.apache.drill" + ".exec.protoB\nUserProtosH\001", 8905); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "User.proto", &protobuf_RegisterTypes); Property::default_instance_ = new Property(); @@ -12284,6 +12285,7 @@ const int ServerMeta::kSystemFunctionsFieldNumber; const int ServerMeta::kTableTermFieldNumber; const int ServerMeta::kTransactionSupportedFieldNumber; const int ServerMeta::kUnionSupportFieldNumber; +const int ServerMeta::kCurrentSchemaFieldNumber; #endif // !_MSC_VER ServerMeta::ServerMeta() @@ -12339,6 +12341,7 @@ void ServerMeta::SharedCtor() { special_characters_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); table_term_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); transaction_supported_ = false; + current_schema_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); ::memset(_has_bits_, 0, sizeof(_has_bits_)); } @@ -12368,6 +12371,9 @@ void ServerMeta::SharedDtor() { if (table_term_ != &::google::protobuf::internal::kEmptyString) { delete table_term_; } + if (current_schema_ != &::google::protobuf::internal::kEmptyString) { + delete current_schema_; + } if (this != default_instance_) { } } @@ -12471,6 +12477,13 @@ void ServerMeta::Clear() { } transaction_supported_ = false; } + if (_has_bits_[49 / 32] & (0xffu << (49 % 32))) { + if (has_current_schema()) { + if (current_schema_ != &::google::protobuf::internal::kEmptyString) { + current_schema_->clear(); + } + } + } collate_support_.Clear(); convert_support_.Clear(); date_time_functions_.Clear(); @@ -13396,6 +13409,23 @@ bool ServerMeta::MergePartialFromCodedStream( goto handle_uninterpreted; } if (input->ExpectTag(392)) goto parse_union_support; + if (input->ExpectTag(402)) goto parse_current_schema; + break; + } + + // optional string current_schema = 50; + case 50: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + parse_current_schema: + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_current_schema())); + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->current_schema().data(), this->current_schema().length(), + ::google::protobuf::internal::WireFormat::PARSE); + } else { + goto handle_uninterpreted; + } if (input->ExpectAtEnd()) return true; break; } @@ -13723,6 +13753,15 @@ void ServerMeta::SerializeWithCachedSizes( 49, this->union_support(i), output); } + // optional string current_schema = 50; + if (has_current_schema()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->current_schema().data(), this->current_schema().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormatLite::WriteString( + 50, this->current_schema(), output); + } + if (!unknown_fields().empty()) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( unknown_fields(), output); @@ -14044,6 +14083,16 @@ void ServerMeta::SerializeWithCachedSizes( 49, this->union_support(i), target); } + // optional string current_schema = 50; + if (has_current_schema()) { + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->current_schema().data(), this->current_schema().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 50, this->current_schema(), target); + } + if (!unknown_fields().empty()) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( unknown_fields(), target); @@ -14302,6 +14351,15 @@ int ServerMeta::ByteSize() const { } } + if (_has_bits_[49 / 32] & (0xffu << (49 % 32))) { + // optional string current_schema = 50; + if (has_current_schema()) { + total_size += 2 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->current_schema()); + } + + } // repeated .exec.user.CollateSupport collate_support = 6; { int data_size = 0; @@ -14565,6 +14623,11 @@ void ServerMeta::MergeFrom(const ServerMeta& from) { set_transaction_supported(from.transaction_supported()); } } + if (from._has_bits_[49 / 32] & (0xffu << (49 % 32))) { + if (from.has_current_schema()) { + set_current_schema(from.current_schema()); + } + } mutable_unknown_fields()->MergeFrom(from.unknown_fields()); } @@ -14639,6 +14702,7 @@ void ServerMeta::Swap(ServerMeta* other) { std::swap(table_term_, other->table_term_); std::swap(transaction_supported_, other->transaction_supported_); union_support_.Swap(&other->union_support_); + std::swap(current_schema_, other->current_schema_); std::swap(_has_bits_[0], other->_has_bits_[0]); std::swap(_has_bits_[1], other->_has_bits_[1]); _unknown_fields_.Swap(&other->_unknown_fields_); diff --git a/contrib/native/client/src/protobuf/User.pb.h b/contrib/native/client/src/protobuf/User.pb.h index b50e8c3..df8a45d 100644 --- a/contrib/native/client/src/protobuf/User.pb.h +++ b/contrib/native/client/src/protobuf/User.pb.h @@ -4567,6 +4567,18 @@ class ServerMeta : public ::google::protobuf::Message { inline const ::google::protobuf::RepeatedField<int>& union_support() const; inline ::google::protobuf::RepeatedField<int>* mutable_union_support(); + // optional string current_schema = 50; + inline bool has_current_schema() const; + inline void clear_current_schema(); + static const int kCurrentSchemaFieldNumber = 50; + inline const ::std::string& current_schema() const; + inline void set_current_schema(const ::std::string& value); + inline void set_current_schema(const char* value); + inline void set_current_schema(const char* value, size_t size); + inline ::std::string* mutable_current_schema(); + inline ::std::string* release_current_schema(); + inline void set_allocated_current_schema(::std::string* current_schema); + // @@protoc_insertion_point(class_scope:exec.user.ServerMeta) private: inline void set_has_all_tables_selectable(); @@ -4643,6 +4655,8 @@ class ServerMeta : public ::google::protobuf::Message { inline void clear_has_table_term(); inline void set_has_transaction_supported(); inline void clear_has_transaction_supported(); + inline void set_has_current_schema(); + inline void clear_has_current_schema(); ::google::protobuf::UnknownFieldSet _unknown_fields_; @@ -4695,9 +4709,10 @@ class ServerMeta : public ::google::protobuf::Message { ::google::protobuf::RepeatedPtrField< ::std::string> system_functions_; ::std::string* table_term_; ::google::protobuf::RepeatedField<int> union_support_; + ::std::string* current_schema_; mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(49 + 31) / 32]; + ::google::protobuf::uint32 _has_bits_[(50 + 31) / 32]; friend void protobuf_AddDesc_User_2eproto(); friend void protobuf_AssignDesc_User_2eproto(); @@ -11602,6 +11617,76 @@ ServerMeta::mutable_union_support() { return &union_support_; } +// optional string current_schema = 50; +inline bool ServerMeta::has_current_schema() const { + return (_has_bits_[1] & 0x00020000u) != 0; +} +inline void ServerMeta::set_has_current_schema() { + _has_bits_[1] |= 0x00020000u; +} +inline void ServerMeta::clear_has_current_schema() { + _has_bits_[1] &= ~0x00020000u; +} +inline void ServerMeta::clear_current_schema() { + if (current_schema_ != &::google::protobuf::internal::kEmptyString) { + current_schema_->clear(); + } + clear_has_current_schema(); +} +inline const ::std::string& ServerMeta::current_schema() const { + return *current_schema_; +} +inline void ServerMeta::set_current_schema(const ::std::string& value) { + set_has_current_schema(); + if (current_schema_ == &::google::protobuf::internal::kEmptyString) { + current_schema_ = new ::std::string; + } + current_schema_->assign(value); +} +inline void ServerMeta::set_current_schema(const char* value) { + set_has_current_schema(); + if (current_schema_ == &::google::protobuf::internal::kEmptyString) { + current_schema_ = new ::std::string; + } + current_schema_->assign(value); +} +inline void ServerMeta::set_current_schema(const char* value, size_t size) { + set_has_current_schema(); + if (current_schema_ == &::google::protobuf::internal::kEmptyString) { + current_schema_ = new ::std::string; + } + current_schema_->assign(reinterpret_cast<const char*>(value), size); +} +inline ::std::string* ServerMeta::mutable_current_schema() { + set_has_current_schema(); + if (current_schema_ == &::google::protobuf::internal::kEmptyString) { + current_schema_ = new ::std::string; + } + return current_schema_; +} +inline ::std::string* ServerMeta::release_current_schema() { + clear_has_current_schema(); + if (current_schema_ == &::google::protobuf::internal::kEmptyString) { + return NULL; + } else { + ::std::string* temp = current_schema_; + current_schema_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + return temp; + } +} +inline void ServerMeta::set_allocated_current_schema(::std::string* current_schema) { + if (current_schema_ != &::google::protobuf::internal::kEmptyString) { + delete current_schema_; + } + if (current_schema) { + set_has_current_schema(); + current_schema_ = current_schema; + } else { + clear_has_current_schema(); + current_schema_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + } +} + // ------------------------------------------------------------------- // RunQuery diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/work/metadata/ServerMetaProvider.java b/exec/java-exec/src/main/java/org/apache/drill/exec/work/metadata/ServerMetaProvider.java index 4f7bffc..97df542 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/work/metadata/ServerMetaProvider.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/work/metadata/ServerMetaProvider.java @@ -138,7 +138,8 @@ public class ServerMetaProvider { .setIdentifierQuoteString(config.quoting().string) .setIdentifierCasing(getIdentifierCasing(config.unquotedCasing(), config.caseSensitive())) .setQuotedIdentifierCasing(getIdentifierCasing(config.quotedCasing(), config.caseSensitive())) - .addAllSqlKeywords(Splitter.on(",").split(metadata.getJdbcKeywords())); + .addAllSqlKeywords(Splitter.on(",").split(metadata.getJdbcKeywords())) + .setCurrentSchema(session.getDefaultSchemaPath()); respBuilder.setServerMeta(metaBuilder); respBuilder.setStatus(RequestStatus.OK); } catch(Throwable t) { diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/work/metadata/TestServerMetaProvider.java b/exec/java-exec/src/test/java/org/apache/drill/exec/work/metadata/TestServerMetaProvider.java index 46f27a6..b8acd2c 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/work/metadata/TestServerMetaProvider.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/work/metadata/TestServerMetaProvider.java @@ -21,28 +21,43 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import org.apache.calcite.avatica.util.Quoting; -import org.apache.drill.test.BaseTestQuery; import org.apache.drill.exec.proto.UserProtos.GetServerMetaResp; import org.apache.drill.exec.proto.UserProtos.RequestStatus; -import org.apache.drill.exec.proto.UserProtos.ServerMeta; +import org.apache.drill.test.ClusterFixture; +import org.apache.drill.test.ClusterFixtureBuilder; +import org.apache.drill.test.ClusterTest; +import org.junit.BeforeClass; import org.junit.Test; -/** - * Tests for server metadata provider APIs. - */ -public class TestServerMetaProvider extends BaseTestQuery { - private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestServerMetaProvider.class); +public class TestServerMetaProvider extends ClusterTest { + + @BeforeClass + public static void setup() throws Exception { + ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher); + startCluster(builder); + } @Test public void testServerMeta() throws Exception { - GetServerMetaResp resp = client.getServerMeta().get(); - assertNotNull(resp); - assertEquals(RequestStatus.OK, resp.getStatus()); - assertNotNull(resp.getServerMeta()); + GetServerMetaResp response = client.client().getServerMeta().get(); + assertNotNull(response); + assertEquals(RequestStatus.OK, response.getStatus()); + assertNotNull(response.getServerMeta()); + + assertEquals(Quoting.BACK_TICK.string, response.getServerMeta().getIdentifierQuoteString()); + } + + @Test + public void testCurrentSchema() throws Exception { + GetServerMetaResp response = client.client().getServerMeta().get(); + assertEquals(RequestStatus.OK, response.getStatus()); + assertEquals("", response.getServerMeta().getCurrentSchema()); - ServerMeta serverMeta = resp.getServerMeta(); - logger.trace("Server metadata: {}", serverMeta); + queryBuilder().sql("use dfs.tmp").run(); - assertEquals(Quoting.BACK_TICK.string, serverMeta.getIdentifierQuoteString()); + response = client.client().getServerMeta().get(); + assertEquals(RequestStatus.OK, response.getStatus()); + assertEquals("dfs.tmp", response.getServerMeta().getCurrentSchema()); } + } diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillConnectionImpl.java b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillConnectionImpl.java index df23f40..d83369e 100644 --- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillConnectionImpl.java +++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillConnectionImpl.java @@ -34,6 +34,7 @@ import java.sql.Struct; import java.util.Map; import java.util.Properties; import java.util.TimeZone; +import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; import org.apache.calcite.avatica.AvaticaConnection; @@ -44,6 +45,7 @@ import org.apache.calcite.avatica.Meta.MetaResultSet; import org.apache.calcite.avatica.NoSuchStatementException; import org.apache.calcite.avatica.QueryState; import org.apache.calcite.avatica.UnregisteredDriver; +import org.apache.commons.lang3.StringUtils; import org.apache.drill.common.config.DrillConfig; import org.apache.drill.common.exceptions.DrillRuntimeException; import org.apache.drill.common.exceptions.UserException; @@ -52,6 +54,8 @@ import org.apache.drill.exec.client.InvalidConnectionInfoException; import org.apache.drill.exec.exception.OutOfMemoryException; import org.apache.drill.exec.memory.BufferAllocator; import org.apache.drill.exec.memory.RootAllocatorFactory; +import org.apache.drill.exec.proto.UserBitShared; +import org.apache.drill.exec.proto.UserProtos; import org.apache.drill.exec.rpc.RpcException; import org.apache.drill.exec.server.Drillbit; import org.apache.drill.exec.server.RemoteServiceSet; @@ -583,6 +587,33 @@ public class DrillConnectionImpl extends AvaticaConnection } @Override + public void setSchema(String schema) throws SQLException { + checkOpen(); + try { + client.runQuery(UserBitShared.QueryType.SQL, String.format("use %s", schema)); + } catch (RpcException e) { + throw new SQLException("Error when setting schema", e); + } + } + + @Override + public String getSchema() throws SQLException { + checkOpen(); + try { + UserProtos.GetServerMetaResp response = client.getServerMeta().get(); + if (response.getStatus() != UserProtos.RequestStatus.OK) { + UserBitShared.DrillPBError drillError = response.getError(); + throw new SQLException("Error when getting server meta: " + drillError.getMessage()); + } + UserProtos.ServerMeta serverMeta = response.getServerMeta(); + String currentSchema = serverMeta.hasCurrentSchema() ? serverMeta.getCurrentSchema() : null; + return StringUtils.isEmpty(currentSchema) ? null : currentSchema; + } catch (InterruptedException | ExecutionException e) { + throw new SQLException("Error when getting server meta", e); + } + } + + @Override public void abort(Executor executor) throws SQLException { checkOpen(); try { diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/ConnectionInfoTest.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/ConnectionInfoTest.java index c24c2b8..c2a3ebd 100644 --- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/ConnectionInfoTest.java +++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/ConnectionInfoTest.java @@ -20,8 +20,11 @@ package org.apache.drill.jdbc; import org.apache.calcite.avatica.util.Quoting; import org.apache.drill.categories.JdbcTest; import org.apache.drill.categories.SlowTest; +import org.junit.After; +import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; +import org.junit.rules.ExpectedException; import java.sql.Connection; import java.sql.DatabaseMetaData; @@ -29,6 +32,8 @@ import java.sql.SQLException; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; /** @@ -36,39 +41,59 @@ import static org.junit.Assert.assertThat; */ @Category({SlowTest.class, JdbcTest.class}) public class ConnectionInfoTest extends JdbcTestBase { - private static Connection connection; - private static DatabaseMetaData dbmd; + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @After + public void tearDown() { + reset(); + } + + @Test + public void testQuotingIdentifiersProperty() throws Exception { + Connection connection = connect("jdbc:drill:zk=local;quoting_identifiers='\"'"); + DatabaseMetaData dbmd = connection.getMetaData(); + assertThat(dbmd.getIdentifierQuoteString(), equalTo(Quoting.DOUBLE_QUOTE.string)); + + reset(); + + connection = connect("jdbc:drill:zk=local;quoting_identifiers=["); + dbmd = connection.getMetaData(); + assertThat(dbmd.getIdentifierQuoteString(), equalTo(Quoting.BRACKET.string)); + } + + @Test + public void testIncorrectCharacterForQuotingIdentifiers() throws Exception { + thrown.expect(SQLException.class); + thrown.expectMessage(containsString("Option planner.parser.quoting_identifiers must be one of: [`, \", []")); + + connect("jdbc:drill:zk=local;quoting_identifiers=&"); + } + + @Test + public void testSetSchemaUsingConnectionMethod() throws Exception { + Connection connection = connect("jdbc:drill:zk=local"); + assertNull(connection.getSchema()); + + connection.setSchema("dfs.tmp"); + assertEquals("dfs.tmp", connection.getSchema()); + } @Test - public void testQuotingIdentifiersProperty() throws SQLException { - try { - // Test DoubleQuotes for the DrillProperty#QUOTING_IDENTIFIERS in connection URL - connection = connect("jdbc:drill:zk=local;quoting_identifiers='\"'"); - dbmd = connection.getMetaData(); - assertThat(dbmd.getIdentifierQuoteString(), equalTo(Quoting.DOUBLE_QUOTE.string)); - reset(); - - // Test Brackets for the DrillProperty#QUOTING_IDENTIFIERS in connection URL - connection = connect("jdbc:drill:zk=local;quoting_identifiers=["); - dbmd = connection.getMetaData(); - assertThat(dbmd.getIdentifierQuoteString(), equalTo(Quoting.BRACKET.string)); - } finally { - reset(); - } + public void testIncorrectlySetSchema() throws Exception { + Connection connection = connect("jdbc:drill:zk=local"); + + thrown.expect(SQLException.class); + thrown.expectMessage("Error when setting schema"); + + connection.setSchema("ABC"); } - @Test(expected = SQLException.class) - public void testIncorrectCharacterForQuotingIdentifiers() throws SQLException { - try { - connection = connect("jdbc:drill:zk=local;quoting_identifiers=&"); - } - catch (SQLException e) { - // Check exception text message - assertThat(e.getMessage(), containsString("Option planner.parser.quoting_identifiers " + - "must be one of: [`, \", []")); - throw e; - } finally { - reset(); - } + @Test + public void testSchemaInConnectionString() throws Exception { + Connection connection = connect("jdbc:drill:zk=local;schema=sys"); + assertEquals("sys", connection.getSchema()); } + } diff --git a/protocol/src/main/java/org/apache/drill/exec/proto/SchemaUserProtos.java b/protocol/src/main/java/org/apache/drill/exec/proto/SchemaUserProtos.java index c1c02ea..899d767 100644 --- a/protocol/src/main/java/org/apache/drill/exec/proto/SchemaUserProtos.java +++ b/protocol/src/main/java/org/apache/drill/exec/proto/SchemaUserProtos.java @@ -4078,6 +4078,8 @@ public final class SchemaUserProtos output.writeBool(48, message.getTransactionSupported(), false); for(org.apache.drill.exec.proto.UserProtos.UnionSupport unionSupport : message.getUnionSupportList()) output.writeEnum(49, unionSupport.getNumber(), true); + if(message.hasCurrentSchema()) + output.writeString(50, message.getCurrentSchema(), false); } public boolean isInitialized(org.apache.drill.exec.proto.UserProtos.ServerMeta message) { @@ -4265,6 +4267,9 @@ public final class SchemaUserProtos case 49: builder.addUnionSupport(org.apache.drill.exec.proto.UserProtos.UnionSupport.valueOf(input.readEnum())); break; + case 50: + builder.setCurrentSchema(input.readString()); + break; default: input.handleUnknownField(number, this); } @@ -4354,6 +4359,7 @@ public final class SchemaUserProtos case 47: return "tableTerm"; case 48: return "transactionSupported"; case 49: return "unionSupport"; + case 50: return "currentSchema"; default: return null; } } @@ -4414,6 +4420,7 @@ public final class SchemaUserProtos fieldMap.put("tableTerm", 47); fieldMap.put("transactionSupported", 48); fieldMap.put("unionSupport", 49); + fieldMap.put("currentSchema", 50); } } diff --git a/protocol/src/main/java/org/apache/drill/exec/proto/UserProtos.java b/protocol/src/main/java/org/apache/drill/exec/proto/UserProtos.java index 6c2685b..d621e94 100644 --- a/protocol/src/main/java/org/apache/drill/exec/proto/UserProtos.java +++ b/protocol/src/main/java/org/apache/drill/exec/proto/UserProtos.java @@ -32959,6 +32959,33 @@ public final class UserProtos { * </pre> */ org.apache.drill.exec.proto.UserProtos.UnionSupport getUnionSupport(int index); + + // optional string current_schema = 50; + /** + * <code>optional string current_schema = 50;</code> + * + * <pre> + * current schema + * </pre> + */ + boolean hasCurrentSchema(); + /** + * <code>optional string current_schema = 50;</code> + * + * <pre> + * current schema + * </pre> + */ + java.lang.String getCurrentSchema(); + /** + * <code>optional string current_schema = 50;</code> + * + * <pre> + * current schema + * </pre> + */ + com.google.protobuf.ByteString + getCurrentSchemaBytes(); } /** * Protobuf type {@code exec.user.ServerMeta} @@ -33473,6 +33500,11 @@ public final class UserProtos { input.popLimit(oldLimit); break; } + case 402: { + bitField1_ |= 0x00000020; + currentSchema_ = input.readBytes(); + break; + } } } } catch (com.google.protobuf.InvalidProtocolBufferException e) { @@ -35145,6 +35177,61 @@ public final class UserProtos { return unionSupport_.get(index); } + // optional string current_schema = 50; + public static final int CURRENT_SCHEMA_FIELD_NUMBER = 50; + private java.lang.Object currentSchema_; + /** + * <code>optional string current_schema = 50;</code> + * + * <pre> + * current schema + * </pre> + */ + public boolean hasCurrentSchema() { + return ((bitField1_ & 0x00000020) == 0x00000020); + } + /** + * <code>optional string current_schema = 50;</code> + * + * <pre> + * current schema + * </pre> + */ + public java.lang.String getCurrentSchema() { + java.lang.Object ref = currentSchema_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + currentSchema_ = s; + } + return s; + } + } + /** + * <code>optional string current_schema = 50;</code> + * + * <pre> + * current schema + * </pre> + */ + public com.google.protobuf.ByteString + getCurrentSchemaBytes() { + java.lang.Object ref = currentSchema_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + currentSchema_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + private void initFields() { allTablesSelectable_ = false; blobIncludedInMaxRowSize_ = false; @@ -35195,6 +35282,7 @@ public final class UserProtos { tableTerm_ = ""; transactionSupported_ = false; unionSupport_ = java.util.Collections.emptyList(); + currentSchema_ = ""; } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { @@ -35361,6 +35449,9 @@ public final class UserProtos { for (int i = 0; i < unionSupport_.size(); i++) { output.writeEnum(49, unionSupport_.get(i).getNumber()); } + if (((bitField1_ & 0x00000020) == 0x00000020)) { + output.writeBytes(50, getCurrentSchemaBytes()); + } getUnknownFields().writeTo(output); } @@ -35621,6 +35712,10 @@ public final class UserProtos { size += dataSize; size += 2 * unionSupport_.size(); } + if (((bitField1_ & 0x00000020) == 0x00000020)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(50, getCurrentSchemaBytes()); + } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; @@ -35840,6 +35935,8 @@ public final class UserProtos { bitField1_ = (bitField1_ & ~0x00008000); unionSupport_ = java.util.Collections.emptyList(); bitField1_ = (bitField1_ & ~0x00010000); + currentSchema_ = ""; + bitField1_ = (bitField1_ & ~0x00020000); return this; } @@ -36087,6 +36184,10 @@ public final class UserProtos { bitField1_ = (bitField1_ & ~0x00010000); } result.unionSupport_ = unionSupport_; + if (((from_bitField1_ & 0x00020000) == 0x00020000)) { + to_bitField1_ |= 0x00000020; + } + result.currentSchema_ = currentSchema_; result.bitField0_ = to_bitField0_; result.bitField1_ = to_bitField1_; onBuilt(); @@ -36365,6 +36466,11 @@ public final class UserProtos { } onChanged(); } + if (other.hasCurrentSchema()) { + bitField1_ |= 0x00020000; + currentSchema_ = other.currentSchema_; + onChanged(); + } this.mergeUnknownFields(other.getUnknownFields()); return this; } @@ -40127,6 +40233,104 @@ public final class UserProtos { return this; } + // optional string current_schema = 50; + private java.lang.Object currentSchema_ = ""; + /** + * <code>optional string current_schema = 50;</code> + * + * <pre> + * current schema + * </pre> + */ + public boolean hasCurrentSchema() { + return ((bitField1_ & 0x00020000) == 0x00020000); + } + /** + * <code>optional string current_schema = 50;</code> + * + * <pre> + * current schema + * </pre> + */ + public java.lang.String getCurrentSchema() { + java.lang.Object ref = currentSchema_; + if (!(ref instanceof java.lang.String)) { + java.lang.String s = ((com.google.protobuf.ByteString) ref) + .toStringUtf8(); + currentSchema_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * <code>optional string current_schema = 50;</code> + * + * <pre> + * current schema + * </pre> + */ + public com.google.protobuf.ByteString + getCurrentSchemaBytes() { + java.lang.Object ref = currentSchema_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + currentSchema_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * <code>optional string current_schema = 50;</code> + * + * <pre> + * current schema + * </pre> + */ + public Builder setCurrentSchema( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField1_ |= 0x00020000; + currentSchema_ = value; + onChanged(); + return this; + } + /** + * <code>optional string current_schema = 50;</code> + * + * <pre> + * current schema + * </pre> + */ + public Builder clearCurrentSchema() { + bitField1_ = (bitField1_ & ~0x00020000); + currentSchema_ = getDefaultInstance().getCurrentSchema(); + onChanged(); + return this; + } + /** + * <code>optional string current_schema = 50;</code> + * + * <pre> + * current schema + * </pre> + */ + public Builder setCurrentSchemaBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField1_ |= 0x00020000; + currentSchema_ = value; + onChanged(); + return this; + } + // @@protoc_insertion_point(builder_scope:exec.user.ServerMeta) } @@ -41921,7 +42125,7 @@ public final class UserProtos { "verMetaResp\022(\n\006status\030\001 \001(\0162\030.exec.user." + "RequestStatus\022*\n\013server_meta\030\002 \001(\0132\025.exe" + "c.user.ServerMeta\022(\n\005error\030\003 \001(\0132\031.exec." + - "shared.DrillPBError\"\377\r\n\nServerMeta\022\035\n\025al" + + "shared.DrillPBError\"\227\016\n\nServerMeta\022\035\n\025al" + "l_tables_selectable\030\001 \001(\010\022%\n\035blob_includ" + "ed_in_max_row_size\030\002 \001(\010\022\030\n\020catalog_at_s" + "tart\030\003 \001(\010\022\031\n\021catalog_separator\030\004 \001(\t\022\024\n" + @@ -41966,70 +42170,70 @@ public final class UserProtos { "ySupport\022\030\n\020system_functions\030. \003(\t\022\022\n\nta" + "ble_term\030/ \001(\t\022\035\n\025transaction_supported\030" + "0 \001(\010\022.\n\runion_support\0301 \003(\0162\027.exec.user" + - ".UnionSupport\"\353\001\n\010RunQuery\0221\n\014results_mo", - "de\030\001 \001(\0162\033.exec.user.QueryResultsMode\022$\n" + - "\004type\030\002 \001(\0162\026.exec.shared.QueryType\022\014\n\004p" + - "lan\030\003 \001(\t\0221\n\tfragments\030\004 \003(\0132\036.exec.bit." + - "control.PlanFragment\022E\n\031prepared_stateme" + - "nt_handle\030\005 \001(\0132\".exec.user.PreparedStat" + - "ementHandle*\320\003\n\007RpcType\022\r\n\tHANDSHAKE\020\000\022\007" + - "\n\003ACK\020\001\022\013\n\007GOODBYE\020\002\022\r\n\tRUN_QUERY\020\003\022\020\n\014C" + - "ANCEL_QUERY\020\004\022\023\n\017REQUEST_RESULTS\020\005\022\027\n\023RE" + - "SUME_PAUSED_QUERY\020\013\022\034\n\030GET_QUERY_PLAN_FR" + - "AGMENTS\020\014\022\020\n\014GET_CATALOGS\020\016\022\017\n\013GET_SCHEM", - "AS\020\017\022\016\n\nGET_TABLES\020\020\022\017\n\013GET_COLUMNS\020\021\022\035\n" + - "\031CREATE_PREPARED_STATEMENT\020\026\022\023\n\017GET_SERV" + - "ER_META\020\010\022\016\n\nQUERY_DATA\020\006\022\020\n\014QUERY_HANDL" + - "E\020\007\022\030\n\024QUERY_PLAN_FRAGMENTS\020\r\022\014\n\010CATALOG" + - "S\020\022\022\013\n\007SCHEMAS\020\023\022\n\n\006TABLES\020\024\022\013\n\007COLUMNS\020" + - "\025\022\026\n\022PREPARED_STATEMENT\020\027\022\017\n\013SERVER_META" + - "\020\t\022\020\n\014QUERY_RESULT\020\n\022\020\n\014SASL_MESSAGE\020\030*H" + - "\n\013SaslSupport\022\030\n\024UNKNOWN_SASL_SUPPORT\020\000\022" + - "\r\n\tSASL_AUTH\020\001\022\020\n\014SASL_PRIVACY\020\002*#\n\020Quer" + - "yResultsMode\022\017\n\013STREAM_FULL\020\001*q\n\017Handsha", - "keStatus\022\013\n\007SUCCESS\020\001\022\030\n\024RPC_VERSION_MIS" + - "MATCH\020\002\022\017\n\013AUTH_FAILED\020\003\022\023\n\017UNKNOWN_FAIL" + - "URE\020\004\022\021\n\rAUTH_REQUIRED\020\005*D\n\rRequestStatu" + - "s\022\022\n\016UNKNOWN_STATUS\020\000\022\006\n\002OK\020\001\022\n\n\006FAILED\020" + - "\002\022\013\n\007TIMEOUT\020\003*Y\n\023ColumnSearchability\022\031\n" + - "\025UNKNOWN_SEARCHABILITY\020\000\022\010\n\004NONE\020\001\022\010\n\004CH" + - "AR\020\002\022\n\n\006NUMBER\020\003\022\007\n\003ALL\020\004*K\n\022ColumnUpdat" + - "ability\022\030\n\024UNKNOWN_UPDATABILITY\020\000\022\r\n\tREA" + - "D_ONLY\020\001\022\014\n\010WRITABLE\020\002*1\n\016CollateSupport" + - "\022\016\n\nCS_UNKNOWN\020\000\022\017\n\013CS_GROUP_BY\020\001*J\n\027Cor", - "relationNamesSupport\022\013\n\007CN_NONE\020\001\022\026\n\022CN_" + - "DIFFERENT_NAMES\020\002\022\n\n\006CN_ANY\020\003*\271\003\n\027DateTi" + - "meLiteralsSupport\022\016\n\nDL_UNKNOWN\020\000\022\013\n\007DL_" + - "DATE\020\001\022\013\n\007DL_TIME\020\002\022\020\n\014DL_TIMESTAMP\020\003\022\024\n" + - "\020DL_INTERVAL_YEAR\020\004\022\025\n\021DL_INTERVAL_MONTH" + - "\020\005\022\023\n\017DL_INTERVAL_DAY\020\006\022\024\n\020DL_INTERVAL_H" + - "OUR\020\007\022\026\n\022DL_INTERVAL_MINUTE\020\010\022\026\n\022DL_INTE" + - "RVAL_SECOND\020\t\022\035\n\031DL_INTERVAL_YEAR_TO_MON" + - "TH\020\n\022\033\n\027DL_INTERVAL_DAY_TO_HOUR\020\013\022\035\n\031DL_" + - "INTERVAL_DAY_TO_MINUTE\020\014\022\035\n\031DL_INTERVAL_", - "DAY_TO_SECOND\020\r\022\036\n\032DL_INTERVAL_HOUR_TO_M" + - "INUTE\020\016\022\036\n\032DL_INTERVAL_HOUR_TO_SECOND\020\017\022" + - " \n\034DL_INTERVAL_MINUTE_TO_SECOND\020\020*Y\n\016Gro" + - "upBySupport\022\013\n\007GB_NONE\020\001\022\022\n\016GB_SELECT_ON" + - "LY\020\002\022\024\n\020GB_BEYOND_SELECT\020\003\022\020\n\014GB_UNRELAT" + - "ED\020\004*x\n\020IdentifierCasing\022\016\n\nIC_UNKNOWN\020\000" + - "\022\023\n\017IC_STORES_LOWER\020\001\022\023\n\017IC_STORES_MIXED" + - "\020\002\022\023\n\017IC_STORES_UPPER\020\003\022\025\n\021IC_SUPPORTS_M" + - "IXED\020\004*X\n\rNullCollation\022\016\n\nNC_UNKNOWN\020\000\022" + - "\017\n\013NC_AT_START\020\001\022\r\n\tNC_AT_END\020\002\022\013\n\007NC_HI", - "GH\020\003\022\n\n\006NC_LOW\020\004*E\n\016OrderBySupport\022\016\n\nOB" + - "_UNKNOWN\020\000\022\020\n\014OB_UNRELATED\020\001\022\021\n\rOB_EXPRE" + - "SSION\020\002*\226\001\n\020OuterJoinSupport\022\016\n\nOJ_UNKNO" + - "WN\020\000\022\013\n\007OJ_LEFT\020\001\022\014\n\010OJ_RIGHT\020\002\022\013\n\007OJ_FU" + - "LL\020\003\022\r\n\tOJ_NESTED\020\004\022\022\n\016OJ_NOT_ORDERED\020\005\022" + - "\014\n\010OJ_INNER\020\006\022\031\n\025OJ_ALL_COMPARISON_OPS\020\007" + - "*\204\001\n\017SubQuerySupport\022\016\n\nSQ_UNKNOWN\020\000\022\021\n\r" + - "SQ_CORRELATED\020\001\022\024\n\020SQ_IN_COMPARISON\020\002\022\020\n" + - "\014SQ_IN_EXISTS\020\003\022\020\n\014SQ_IN_INSERT\020\004\022\024\n\020SQ_" + - "IN_QUANTIFIED\020\005*;\n\014UnionSupport\022\r\n\tU_UNK", - "NOWN\020\000\022\013\n\007U_UNION\020\001\022\017\n\013U_UNION_ALL\020\002B+\n\033" + - "org.apache.drill.exec.protoB\nUserProtosH" + - "\001" + ".UnionSupport\022\026\n\016current_schema\0302 \001(\t\"\353\001", + "\n\010RunQuery\0221\n\014results_mode\030\001 \001(\0162\033.exec." + + "user.QueryResultsMode\022$\n\004type\030\002 \001(\0162\026.ex" + + "ec.shared.QueryType\022\014\n\004plan\030\003 \001(\t\0221\n\tfra" + + "gments\030\004 \003(\0132\036.exec.bit.control.PlanFrag" + + "ment\022E\n\031prepared_statement_handle\030\005 \001(\0132" + + "\".exec.user.PreparedStatementHandle*\320\003\n\007" + + "RpcType\022\r\n\tHANDSHAKE\020\000\022\007\n\003ACK\020\001\022\013\n\007GOODB" + + "YE\020\002\022\r\n\tRUN_QUERY\020\003\022\020\n\014CANCEL_QUERY\020\004\022\023\n" + + "\017REQUEST_RESULTS\020\005\022\027\n\023RESUME_PAUSED_QUER" + + "Y\020\013\022\034\n\030GET_QUERY_PLAN_FRAGMENTS\020\014\022\020\n\014GET", + "_CATALOGS\020\016\022\017\n\013GET_SCHEMAS\020\017\022\016\n\nGET_TABL" + + "ES\020\020\022\017\n\013GET_COLUMNS\020\021\022\035\n\031CREATE_PREPARED" + + "_STATEMENT\020\026\022\023\n\017GET_SERVER_META\020\010\022\016\n\nQUE" + + "RY_DATA\020\006\022\020\n\014QUERY_HANDLE\020\007\022\030\n\024QUERY_PLA" + + "N_FRAGMENTS\020\r\022\014\n\010CATALOGS\020\022\022\013\n\007SCHEMAS\020\023" + + "\022\n\n\006TABLES\020\024\022\013\n\007COLUMNS\020\025\022\026\n\022PREPARED_ST" + + "ATEMENT\020\027\022\017\n\013SERVER_META\020\t\022\020\n\014QUERY_RESU" + + "LT\020\n\022\020\n\014SASL_MESSAGE\020\030*H\n\013SaslSupport\022\030\n" + + "\024UNKNOWN_SASL_SUPPORT\020\000\022\r\n\tSASL_AUTH\020\001\022\020" + + "\n\014SASL_PRIVACY\020\002*#\n\020QueryResultsMode\022\017\n\013", + "STREAM_FULL\020\001*q\n\017HandshakeStatus\022\013\n\007SUCC" + + "ESS\020\001\022\030\n\024RPC_VERSION_MISMATCH\020\002\022\017\n\013AUTH_" + + "FAILED\020\003\022\023\n\017UNKNOWN_FAILURE\020\004\022\021\n\rAUTH_RE" + + "QUIRED\020\005*D\n\rRequestStatus\022\022\n\016UNKNOWN_STA" + + "TUS\020\000\022\006\n\002OK\020\001\022\n\n\006FAILED\020\002\022\013\n\007TIMEOUT\020\003*Y" + + "\n\023ColumnSearchability\022\031\n\025UNKNOWN_SEARCHA" + + "BILITY\020\000\022\010\n\004NONE\020\001\022\010\n\004CHAR\020\002\022\n\n\006NUMBER\020\003" + + "\022\007\n\003ALL\020\004*K\n\022ColumnUpdatability\022\030\n\024UNKNO" + + "WN_UPDATABILITY\020\000\022\r\n\tREAD_ONLY\020\001\022\014\n\010WRIT" + + "ABLE\020\002*1\n\016CollateSupport\022\016\n\nCS_UNKNOWN\020\000", + "\022\017\n\013CS_GROUP_BY\020\001*J\n\027CorrelationNamesSup" + + "port\022\013\n\007CN_NONE\020\001\022\026\n\022CN_DIFFERENT_NAMES\020" + + "\002\022\n\n\006CN_ANY\020\003*\271\003\n\027DateTimeLiteralsSuppor" + + "t\022\016\n\nDL_UNKNOWN\020\000\022\013\n\007DL_DATE\020\001\022\013\n\007DL_TIM" + + "E\020\002\022\020\n\014DL_TIMESTAMP\020\003\022\024\n\020DL_INTERVAL_YEA" + + "R\020\004\022\025\n\021DL_INTERVAL_MONTH\020\005\022\023\n\017DL_INTERVA" + + "L_DAY\020\006\022\024\n\020DL_INTERVAL_HOUR\020\007\022\026\n\022DL_INTE" + + "RVAL_MINUTE\020\010\022\026\n\022DL_INTERVAL_SECOND\020\t\022\035\n" + + "\031DL_INTERVAL_YEAR_TO_MONTH\020\n\022\033\n\027DL_INTER" + + "VAL_DAY_TO_HOUR\020\013\022\035\n\031DL_INTERVAL_DAY_TO_", + "MINUTE\020\014\022\035\n\031DL_INTERVAL_DAY_TO_SECOND\020\r\022" + + "\036\n\032DL_INTERVAL_HOUR_TO_MINUTE\020\016\022\036\n\032DL_IN" + + "TERVAL_HOUR_TO_SECOND\020\017\022 \n\034DL_INTERVAL_M" + + "INUTE_TO_SECOND\020\020*Y\n\016GroupBySupport\022\013\n\007G" + + "B_NONE\020\001\022\022\n\016GB_SELECT_ONLY\020\002\022\024\n\020GB_BEYON" + + "D_SELECT\020\003\022\020\n\014GB_UNRELATED\020\004*x\n\020Identifi" + + "erCasing\022\016\n\nIC_UNKNOWN\020\000\022\023\n\017IC_STORES_LO" + + "WER\020\001\022\023\n\017IC_STORES_MIXED\020\002\022\023\n\017IC_STORES_" + + "UPPER\020\003\022\025\n\021IC_SUPPORTS_MIXED\020\004*X\n\rNullCo" + + "llation\022\016\n\nNC_UNKNOWN\020\000\022\017\n\013NC_AT_START\020\001", + "\022\r\n\tNC_AT_END\020\002\022\013\n\007NC_HIGH\020\003\022\n\n\006NC_LOW\020\004" + + "*E\n\016OrderBySupport\022\016\n\nOB_UNKNOWN\020\000\022\020\n\014OB" + + "_UNRELATED\020\001\022\021\n\rOB_EXPRESSION\020\002*\226\001\n\020Oute" + + "rJoinSupport\022\016\n\nOJ_UNKNOWN\020\000\022\013\n\007OJ_LEFT\020" + + "\001\022\014\n\010OJ_RIGHT\020\002\022\013\n\007OJ_FULL\020\003\022\r\n\tOJ_NESTE" + + "D\020\004\022\022\n\016OJ_NOT_ORDERED\020\005\022\014\n\010OJ_INNER\020\006\022\031\n" + + "\025OJ_ALL_COMPARISON_OPS\020\007*\204\001\n\017SubQuerySup" + + "port\022\016\n\nSQ_UNKNOWN\020\000\022\021\n\rSQ_CORRELATED\020\001\022" + + "\024\n\020SQ_IN_COMPARISON\020\002\022\020\n\014SQ_IN_EXISTS\020\003\022" + + "\020\n\014SQ_IN_INSERT\020\004\022\024\n\020SQ_IN_QUANTIFIED\020\005*", + ";\n\014UnionSupport\022\r\n\tU_UNKNOWN\020\000\022\013\n\007U_UNIO" + + "N\020\001\022\017\n\013U_UNION_ALL\020\002B+\n\033org.apache.drill" + + ".exec.protoB\nUserProtosH\001" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { @@ -42215,7 +42419,7 @@ public final class UserProtos { internal_static_exec_user_ServerMeta_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_exec_user_ServerMeta_descriptor, - new java.lang.String[] { "AllTablesSelectable", "BlobIncludedInMaxRowSize", "CatalogAtStart", "CatalogSeparator", "CatalogTerm", "CollateSupport", "ColumnAliasingSupported", "ConvertSupport", "CorrelationNamesSupport", "DateTimeFunctions", "DateTimeLiteralsSupport", "GroupBySupport", "IdentifierCasing", "IdentifierQuoteString", "LikeEscapeClauseSupported", "MaxBinaryLiteralLength", "MaxCatalogNameLength", "MaxCharLiteralLength", "MaxColumnNameLength", "MaxColumnsInGroupBy", [...] + new java.lang.String[] { "AllTablesSelectable", "BlobIncludedInMaxRowSize", "CatalogAtStart", "CatalogSeparator", "CatalogTerm", "CollateSupport", "ColumnAliasingSupported", "ConvertSupport", "CorrelationNamesSupport", "DateTimeFunctions", "DateTimeLiteralsSupport", "GroupBySupport", "IdentifierCasing", "IdentifierQuoteString", "LikeEscapeClauseSupported", "MaxBinaryLiteralLength", "MaxCatalogNameLength", "MaxCharLiteralLength", "MaxColumnNameLength", "MaxColumnsInGroupBy", [...] internal_static_exec_user_RunQuery_descriptor = getDescriptor().getMessageTypes().get(30); internal_static_exec_user_RunQuery_fieldAccessorTable = new diff --git a/protocol/src/main/java/org/apache/drill/exec/proto/beans/ServerMeta.java b/protocol/src/main/java/org/apache/drill/exec/proto/beans/ServerMeta.java index f05783a..d5032f9 100644 --- a/protocol/src/main/java/org/apache/drill/exec/proto/beans/ServerMeta.java +++ b/protocol/src/main/java/org/apache/drill/exec/proto/beans/ServerMeta.java @@ -98,6 +98,7 @@ public final class ServerMeta implements Externalizable, Message<ServerMeta>, Sc private String tableTerm; private Boolean transactionSupported; private List<UnionSupport> unionSupport; + private String currentSchema; public ServerMeta() { @@ -743,6 +744,19 @@ public final class ServerMeta implements Externalizable, Message<ServerMeta>, Sc return this; } + // currentSchema + + public String getCurrentSchema() + { + return currentSchema; + } + + public ServerMeta setCurrentSchema(String currentSchema) + { + this.currentSchema = currentSchema; + return this; + } + // java serialization public void readExternal(ObjectInput in) throws IOException @@ -969,6 +983,9 @@ public final class ServerMeta implements Externalizable, Message<ServerMeta>, Sc message.unionSupport = new ArrayList<UnionSupport>(); message.unionSupport.add(UnionSupport.valueOf(input.readEnum())); break; + case 50: + message.currentSchema = input.readString(); + break; default: input.handleUnknownField(number, this); } @@ -1197,6 +1214,9 @@ public final class ServerMeta implements Externalizable, Message<ServerMeta>, Sc output.writeEnum(49, unionSupport.number, true); } } + + if(message.currentSchema != null) + output.writeString(50, message.currentSchema, false); } public String getFieldName(int number) @@ -1252,6 +1272,7 @@ public final class ServerMeta implements Externalizable, Message<ServerMeta>, Sc case 47: return "tableTerm"; case 48: return "transactionSupported"; case 49: return "unionSupport"; + case 50: return "currentSchema"; default: return null; } } @@ -1314,6 +1335,7 @@ public final class ServerMeta implements Externalizable, Message<ServerMeta>, Sc __fieldMap.put("tableTerm", 47); __fieldMap.put("transactionSupported", 48); __fieldMap.put("unionSupport", 49); + __fieldMap.put("currentSchema", 50); } } diff --git a/protocol/src/main/protobuf/User.proto b/protocol/src/main/protobuf/User.proto index 2af8b26..8c1a3a2 100644 --- a/protocol/src/main/protobuf/User.proto +++ b/protocol/src/main/protobuf/User.proto @@ -652,6 +652,8 @@ message ServerMeta { optional bool transaction_supported = 48; // UNION support repeated UnionSupport union_support = 49; + // current schema + optional string current_schema = 50; } /*
