@@ -62,6 +62,32 @@ class HiveDriver extends BaseDriver {
62
62
) ;
63
63
const hiveConnection = new HiveConnection ( configuration , idl ) ;
64
64
hiveConnection . cursor = await hiveConnection . connect ( ) ;
65
+ hiveConnection . cursor . getOperationStatus = function ( ) {
66
+ return new Promise ( ( resolve , reject ) => {
67
+ const serviceType = this . Conn . IDL . ServiceType ;
68
+ const request = new serviceType . TGetOperationStatusReq ( {
69
+ operationHandle : this . OperationHandle ,
70
+ } ) ;
71
+
72
+ this . Client . GetOperationStatus ( request , ( err , res ) => {
73
+ if ( err ) {
74
+ reject ( new Error ( err ) ) ;
75
+ } else if (
76
+ res . status . statusCode === serviceType . TStatusCode . ERROR_STATUS ||
77
+ res . operationState === serviceType . TOperationState . ERROR_STATE
78
+ ) {
79
+ // eslint-disable-next-line no-unused-vars
80
+ const [ errorMessage , infoMessage , message ] = HS2Util . getThriftErrorMessage (
81
+ res . status , 'ExecuteStatement operation fail'
82
+ ) ;
83
+
84
+ reject ( new Error ( res . errorMessage || message ) ) ;
85
+ } else {
86
+ resolve ( res . operationState ) ;
87
+ }
88
+ } ) ;
89
+ } ) ;
90
+ } ;
65
91
return hiveConnection ;
66
92
} ,
67
93
destroy : ( connection ) => connection . close ( )
@@ -119,7 +145,7 @@ class HiveDriver extends BaseDriver {
119
145
}
120
146
allRows = allRows . map (
121
147
row => schema
122
- . map ( ( column , i ) => ( { [ column . columnName . replace ( / ^ _ u ( .+ ?) \. / , '' ) ] : row [ i ] } ) )
148
+ . map ( ( column , i ) => ( { [ column . columnName . replace ( / ^ _ u ( .+ ?) \. / , '' ) ] : row [ i ] === 'NULL' ? null : row [ i ] } ) ) // TODO NULL
123
149
. reduce ( ( a , b ) => ( { ...a , ...b } ) , { } )
124
150
) ;
125
151
}
@@ -136,9 +162,10 @@ class HiveDriver extends BaseDriver {
136
162
137
163
return {
138
164
[ this . config . dbName ] : ( await Promise . all ( tables . map ( async table => {
139
- const columns = await this . query ( `describe ${ this . config . dbName } .${ table . tab_name } ` ) ;
165
+ const tableName = table . tab_name || table . tableName ;
166
+ const columns = await this . query ( `describe ${ this . config . dbName } .${ tableName } ` ) ;
140
167
return {
141
- [ table . tab_name ] : columns . map ( c => ( { name : c . col_name , type : c . data_type } ) )
168
+ [ tableName ] : columns . map ( c => ( { name : c . col_name , type : c . data_type } ) )
142
169
} ;
143
170
} ) ) ) . reduce ( ( a , b ) => ( { ...a , ...b } ) , { } )
144
171
} ;
0 commit comments