|
@@ -17,6 +17,10 @@
|
|
|
import ApiHelper from 'api/apiHelper';
|
|
import ApiHelper from 'api/apiHelper';
|
|
|
import { matchesType } from './typeUtils';
|
|
import { matchesType } from './typeUtils';
|
|
|
import I18n from 'utils/i18n';
|
|
import I18n from 'utils/i18n';
|
|
|
|
|
+import huePubSub from 'utils/huePubSub';
|
|
|
|
|
+import { clearUdfCache, getCachedApiUdfs, setCachedApiUdfs } from './sqlReferenceRepositoryCache';
|
|
|
|
|
+
|
|
|
|
|
+export const CLEAR_UDF_CACHE_EVENT = 'hue.clear.udf.cache';
|
|
|
|
|
|
|
|
const SET_REFS = {
|
|
const SET_REFS = {
|
|
|
impala: async () => import(/* webpackChunkName: "impala-ref" */ './impala/setReference')
|
|
impala: async () => import(/* webpackChunkName: "impala-ref" */ './impala/setReference')
|
|
@@ -69,6 +73,7 @@ const findUdfsToAdd = (apiUdfs, existingCategories) => {
|
|
|
const result = {};
|
|
const result = {};
|
|
|
|
|
|
|
|
apiUdfs.forEach(apiUdf => {
|
|
apiUdfs.forEach(apiUdf => {
|
|
|
|
|
+ // TODO: Impala reports the same UDF multiple times, once per argument type.
|
|
|
if (
|
|
if (
|
|
|
!result[apiUdf.name] &&
|
|
!result[apiUdf.name] &&
|
|
|
!existingUdfNames.has(apiUdf.name.toUpperCase()) &&
|
|
!existingUdfNames.has(apiUdf.name.toUpperCase()) &&
|
|
@@ -82,11 +87,15 @@ const findUdfsToAdd = (apiUdfs, existingCategories) => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const mergeWithApiUdfs = async (categories, connector, database) => {
|
|
const mergeWithApiUdfs = async (categories, connector, database) => {
|
|
|
- const apiUdfs = await ApiHelper.fetchUdfs({
|
|
|
|
|
- connector: connector,
|
|
|
|
|
- database: database,
|
|
|
|
|
- silenceErrors: true
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ let apiUdfs = await getCachedApiUdfs(connector, database);
|
|
|
|
|
+ if (!apiUdfs) {
|
|
|
|
|
+ apiUdfs = await ApiHelper.fetchUdfs({
|
|
|
|
|
+ connector: connector,
|
|
|
|
|
+ database: database,
|
|
|
|
|
+ silenceErrors: true
|
|
|
|
|
+ });
|
|
|
|
|
+ await setCachedApiUdfs(connector, database, apiUdfs);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (apiUdfs.length) {
|
|
if (apiUdfs.length) {
|
|
|
const additionalUdfs = findUdfsToAdd(apiUdfs, categories);
|
|
const additionalUdfs = findUdfsToAdd(apiUdfs, categories);
|