Fix Schema Tree · apache/drill@09690cf · GitHub
Skip to content

Commit 09690cf

Browse files
committed
Fix Schema Tree
1 parent 4516444 commit 09690cf

3 files changed

Lines changed: 52 additions & 6 deletions

File tree

‎exec/java-exec/src/main/resources/webapp/src/components/schema-explorer/SchemaExplorer.tsx‎

Lines changed: 18 additions & 3 deletions

‎exec/java-exec/src/main/resources/webapp/src/components/schema-explorer/TreeNodeBuilder.test.tsx‎

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
* limitations under the License.
1717
*/
1818
import { describe, it, expect, vi } from 'vitest';
19-
import { buildColumnNodes, buildTableNodes } from './TreeNodeBuilder';
19+
import { buildColumnNodes, buildPluginNode, buildTableNodes } from './TreeNodeBuilder';
2020
import type { UsageCounts } from './TreeNodeBuilder';
21-
import type { ColumnInfo, TableInfo } from '../../types';
21+
import type { ColumnInfo, PluginInfo, TableInfo } from '../../types';
2222
import type { ReactElement } from 'react';
2323
import { EyeOutlined, TableOutlined, ThunderboltOutlined } from '@ant-design/icons';
2424

@@ -234,3 +234,28 @@ describe('buildTableNodes icons', () => {
234234
expect(iconOf('MATERIALIZED VIEW')).toBe(ThunderboltOutlined);
235235
});
236236
});
237+
238+
describe('buildPluginNode', () => {
239+
const plugin: PluginInfo = { name: 'splunk', type: 'splunk', enabled: true, browsable: true };
240+
241+
it('collapses a lone schema named after the plugin', () => {
242+
const node = buildPluginNode(
243+
plugin,
244+
{ splunk: [{ name: 'splunk', plugin: 'splunk', type: 'schema', browsable: true }] },
245+
{ splunk: [{ name: 'main', schema: 'splunk', type: 'TABLE' }] },
246+
{}, {}, {}, {},
247+
);
248+
249+
expect(node.children?.map((c) => c.key)).toEqual(['table:splunk:main']);
250+
});
251+
252+
it('keeps the schema level when schemas differ from the plugin name', () => {
253+
const node = buildPluginNode(
254+
plugin,
255+
{ splunk: [{ name: 'splunk.audit', plugin: 'splunk', type: 'schema', browsable: true }] },
256+
{}, {}, {}, {}, {},
257+
);
258+
259+
expect(node.children?.map((c) => c.key)).toEqual(['schema:splunk.audit']);
260+
});
261+
});

‎exec/java-exec/src/main/resources/webapp/src/components/schema-explorer/TreeNodeBuilder.tsx‎

Lines changed: 7 additions & 1 deletion

0 commit comments

Comments
 (0)