Thanks @Romain. We have Hive all setup and installed and it works fine via the web interface. The network tab in Chrome shows a lot more fields are being sent than are specified in the API doc, I’m not sure if this is significant and if they are all needed? I tried an AJAX request with just the “snippet” fields:
$.ajax({
url: "notebook/api/execute/hive/",
type: 'POST',
beforeSend: function(request) {
request.setRequestHeader("Content-Type", 'application/x-www-form-urlencoded; charset=UTF-8');
},
data: {"snippet": {"id":"b2643bcfe-9e9b-6354-8dbc-8a2563f7254cb","type":"hive","status":"running","statementType":"text","statement":"SELECT 1;","aceCursorPosition":{"column":9,"row":0},"statementPath":"","associatedDocumentUuid":null,"properties":{"files":[],"functions":[],"arguments":[],"settings":[]},"result":{"id":"b2643bcfe-9e9b-6354-8dbc-8a2563f7254cb","type":"table","handle":{"has_more_statements":false,"statement_id":0,"statements_count":1,"previous_statement_hash":"ef10d24b9fdfe97deed746bb839573afef8647de5"}},"database":"default","wasBatchExecuted":false}},
success: function(data) { console.log(data); },
error: function(err) { console.log(err); }
});
which gives me a 500 internal server error and this is the relevant part of the response:
Exception Type: TypeError at /hue/notebook/api/execute/hive/
Exception Value: <desktop.appmanager.DesktopModuleInfo object at 0x2f37250> is not JSON serializable
Request information:
GET: No GET data
POST:
snippet[statementType] = u'text'
snippet[id] = u'b2643bcfe-9e9b-6354-8dbc-8a2563f7254cb'
snippet[aceCursorPosition][row] = u'0'
snippet[status] = u'running'
snippet[result][handle][statements_count] = u'1'
snippet[associatedDocumentUuid] = u''
snippet[type] = u'hive'
snippet[database] = u'default'
snippet[statementPath] = u''
snippet[result][handle][has_more_statements] = u'false'
snippet[result][handle][previous_statement_hash] = u'ef10d24b9fdfe97deed746bb839573afef8647de5'
snippet[result][id] = u'b2643bcfe-9e9b-6354-8dbc-8a2563f7254cb'
snippet[result][type] = u'table'
snippet[aceCursorPosition][column] = u'9'
snippet[result][handle][statement_id] = u'0'
snippet[statement] = u'SELECT 1;'
snippet[wasBatchExecuted] = u'false'
I also get the same Exception error message if I try with the “notebook” fields as well (this is all the form data that the web interface is sending when it successfully works), so my request is:
$.ajax({
url: "notebook/api/execute/hive/",
type: 'POST',
beforeSend: function(request) {
request.setRequestHeader("Content-Type", 'application/x-www-form-urlencoded; charset=UTF-8');
},
data: {"notebook": {"id":24989,"uuid":"b2643bcfe-9e9b-6354-8dbc-8a2563f7254cb","name":"Hive test","description":"test hive editor","type":"query-hive","initialType":"hive","coordinatorUuid":null,"isHistory":true,"isManaged":false,"parentSavedQueryUuid":"b2643bcfe-9e9b-6354-8dbc-8a2563f7254cb","isSaved":true,"onSuccessUrl":null,"pubSubUrl":null,"isPresentationModeDefault":false,"isPresentationMode":false,"presentationSnippets":{},"isHidingCode":false,"snippets":[{"id":"b2643bcfe-9e9b-6354-8dbc-8a2563f7254cb","name":"","type":"hive","isBatchable":true,"aceCursorPosition":{"column":9,"row":0},"errors":[],"aceErrorsHolder":[],"aceWarningsHolder":[],"aceErrors":[],"aceWarnings":[],"editorMode":true,"dbSelectionVisible":false,"isSqlDialect":true,"database":"default","currentQueryTab":"queryHistory","pinnedContextTabs":[],"loadingQueries":false,"queriesHasErrors":false,"queriesCurrentPage":1,"queriesTotalPages":1,"queriesFilter":"","queriesFilterVisible":false,"statementType":"text","statementTypes":["text","file"],"statementPath":"","externalStatementLoaded":false,"associatedDocumentLoading":true,"associatedDocumentUuid":null,"statement_raw":"SELECT 1;","statementsList":["SELECT 1;"],"aceSize":100,"status":"running","statusForButtons":"executing","properties":{"files":[],"functions":[],"arguments":[],"settings":[]},"viewSettings":{"placeHolder":"Example: SELECT * FROM tablename, or press CTRL + space","sqlDialect":true},"variables":[],"hasCurlyBracketParameters":true,"variableNames":[],"variableValues":{},"statement":"SELECT 1;","result":{"id":"b2643bcfe-9e9b-6354-8dbc-8a2563f7254cb","type":"table","hasResultset":true,"handle":{"has_more_statements":false,"statement_id":0,"statements_count":1,"previous_statement_hash":"ef10d24b9fdfe97deed746bb839573afef8647de5"},"meta":[],"rows":null,"hasMore":false,"statement_id":0,"statement_range":{"start":{"row":0,"column":0},"end":{"row":0,"column":0}},"statements_count":1,"metaFilter":{"query":"","facets":{},"text":[]},"isMetaFilterVisible":false,"filteredMetaChecked":true,"filteredMeta":[],"fetchedOnce":false,"startTime":"2021-02-18T14:42:25.058Z","endTime":"2021-02-18T14:42:25.058Z","executionTime":0,"data":[],"explanation":"","logs":"","logLines":0,"hasSomeResults":true},"showGrid":true,"showChart":false,"showLogs":true,"progress":0,"jobs":[],"isLoading":false,"resultsKlass":"results hive","errorsKlass":"results hive alert alert-error","is_redacted":false,"chartType":"bars","chartSorting":"none","chartScatterGroup":null,"chartScatterSize":null,"chartScope":"world","chartTimelineType":"bar","chartLimits":[5,10,25,50,100],"chartLimit":null,"chartX":null,"chartXPivot":null,"chartYSingle":null,"chartYMulti":["_c0"],"chartData":[],"chartMapType":"marker","chartMapLabel":null,"chartMapHeat":null,"hasDataForChart":false,"previousChartOptions":{"chartLimit":null,"chartX":null,"chartXPivot":null,"chartYSingle":null,"chartMapType":"marker","chartMapLabel":null,"chartMapHeat":null,"chartYMulti":["_c0"],"chartScope":"world","chartTimelineType":"bar","chartSorting":"none","chartScatterGroup":null,"chartScatterSize":null},"isResultSettingsVisible":false,"settingsVisible":false,"checkStatusTimeout":null,"topRisk":null,"suggestion":"","hasSuggestion":null,"compatibilityCheckRunning":false,"compatibilitySourcePlatform":"hive","compatibilitySourcePlatforms":[{"name":"Teradata","value":"teradata"},{"name":"Oracle","value":"oracle"},{"name":"Netezza","value":"netezza"},{"name":"Impala","value":"impala"},{"name":"Hive","value":"hive"},{"name":"DB2","value":"db2"},{"name":"Greenplum","value":"greenplum"},{"name":"MySQL","value":"mysql"},{"name":"PostgreSQL","value":"postgresql"},{"name":"Informix","value":"informix"},{"name":"SQL Server","value":"sqlserver"},{"name":"Sybase","value":"sybase"},{"name":"Access","value":"access"},{"name":"Firebird","value":"firebird"},{"name":"ANSISQL","value":"ansisql"},{"name":"Generic","value":"generic"}],"compatibilityTargetPlatform":"hive","compatibilityTargetPlatforms":[{"name":"Impala","value":"impala"},{"name":"Hive","value":"hive"}],"showOptimizer":false,"wasBatchExecuted":false,"isReady":true,"lastExecuted":1613659345047,"lastAceSelectionRowOffset":0,"executingBlockingOperation":null,"showLongOperationWarning":false,"formatEnabled":true,"isFetchingData":false,"isCanceling":false}],"selectedSnippet":"hive","creatingSessionLocks":[],"sessions":[{"type":"hive","properties":[{"multiple":true,"defaultValue":[],"value":[],"nice_name":"Files","key":"files","help_text":"Add one or more files, jars, or archives to the list of resources.","type":"hdfs-files"},{"multiple":true,"defaultValue":[],"value":[],"nice_name":"Functions","key":"functions","help_text":"Add one or more registered UDFs (requires function name and fully-qualified class name).","type":"functions"},{"nice_name":"Settings","multiple":true,"key":"settings","help_text":"Hive and Hadoop configuration properties.","defaultValue":[],"type":"settings","options":["hive.map.aggr","hive.exec.compress.output","hive.exec.parallel","hive.execution.engine","mapreduce.job.queuename"],"value":[]}],"reuse_session":true,"id":5349,"session_id":"b2643bcfe-9e9b-6354-8dbc-8a2563f7254cb"}],"directoryUuid":"","dependentsCoordinator":[],"historyFilter":"","historyFilterVisible":false,"loadingHistory":false,"historyInitialHeight":4238.011364,"forceHistoryInitialHeight":true,"historyCurrentPage":1,"historyTotalPages":5,"schedulerViewModel":null,"schedulerViewModelIsLoaded":false,"isBatchable":true,"isExecutingAll":false,"executingAllIndex":0,"retryModalConfirm":null,"retryModalCancel":null,"unloaded":false,"updateHistoryFailed":false,"viewSchedulerId":"","loadingScheduler":false}, "snippet": {"id":"b2643bcfe-9e9b-6354-8dbc-8a2563f7254cb","type":"hive","status":"running","statementType":"text","statement":"SELECT 1;","aceCursorPosition":{"column":9,"row":0},"statementPath":"","associatedDocumentUuid":null,"properties":{"files":[],"functions":[],"arguments":[],"settings":[]},"result":{"id":"b2643bcfe-9e9b-6354-8dbc-8a2563f7254cb","type":"table","handle":{"has_more_statements":false,"statement_id":0,"statements_count":1,"previous_statement_hash":"ef10d24b9fdfe97deed746bb839573afef8647de5"}},"database":"default","wasBatchExecuted":false}},
success: function(data) { console.log(data); },
error: function(err) { console.log(err); }
});
I believe this is very close to working but I just need the syntax right! We are using Hue 4 by the way but I am not sure which minor version.
Thanks