Import columns from SQL

Instead of adding columns one by one, paste a SELECT statement and let DataMind OS detect the column definitions for you. The import lives on the Columns step of both a Dictionary and a Dimension or Fact table. The grid itself, with its rules and its save, is on Define table columns.

Note

Importing columns is separate from the SQL that fills a dictionary. The queries that populate a dictionary live on the Queries step; see Dictionary queries.

Import columns from a SELECT

  1. Open the table and go to the Columns step. On a table that is not saved yet, save the General step first. Until then the import button is disabled, and its tooltip reads Save general settings first.
  2. Click the import button in the columns toolbar. Its tooltip reads Import columns from SQL script. In a Dictionary it opens a small popover; in a Dimension or Fact table it opens a window with a run button and a result preview.
  3. Paste a SELECT statement. Both windows say "Paste a SELECT statement to detect column definitions." The Dictionary popover shows the expected shape in its placeholder: SELECT id, name, email FROM users....
  4. Optionally, check the statement before importing (Dimension and Fact tables only); the next section explains how.
  5. Click Import. In the Dictionary popover you can also press Enter to import; Import stays disabled until the box has text. While the import runs, the button reads Importing….
  6. The detected columns appear as new rows in the grid. Adjust them like any other column.
  7. Click Apply to keep them.

Check the statement before importing

In a Dimension or Fact table, the import window can run the statement and show the result before anything is imported.

  1. Click Run Query. Its title reads Run query (Ctrl+Enter); you can also press Ctrl+Enter. The button reads Running… while the statement runs.
  2. The result opens in a grid, so you can confirm the columns and their types. You can also export the result.
  3. If the statement fails, the Query Validation Error window opens with the details. Click Fix with AI, and when DataMind OS offers a corrected statement, review it in the Query Difference Checker and click Apply Changes to use it.

When the fix cannot be made, one of these messages appears:

What gets imported

If the import finds nothing or fails

What you seeWhat it means
No columns found, with "No columns were detected in the SQL script."The statement returned no columns. Check that it is a SELECT whose result has columns, then import again.
Import Failed, with "Failed to import columns from SQL."The import could not run, and nothing was added. Check the statement and try again.

Questions, answered

Why is the import button disabled?

The table is not saved yet, so there is nothing to attach the columns to. Save the General step first; until then the button's tooltip reads Save general settings first.

Does the import remember the SQL I pasted?

It depends on the window. In a Dimension or Fact table, the import window reloads the last statement you used when you reopen it. The Dictionary popover clears its statement when it closes, so paste it again.

Why did the import say no columns were found?

The statement returned no columns. Check that it is a SELECT whose result has columns, then import again.

Does the import copy data as well as columns?

No. It detects column definitions only, and no rows are imported. Rows reach a table through its transformations or its queries.

Why do imported columns have names like name_1?

A column with that name already exists, so DataMind OS adds a suffix. Rename the column in the grid before you apply if you want a different name.

Which keyboard shortcuts work in the import windows?

In the Dictionary popover: Enter imports the statement, Shift+Enter starts a new line, and Escape closes the popover. In the Dimension or Fact window: Ctrl+Enter runs the statement.

How does Fix with AI repair a failed statement?

It offers a corrected statement in the Query Difference Checker. If it looks right, click Apply Changes to put it into the editor. If the table is not saved yet, the fix is refused with Cannot fix query; save the General step and try again.

What are imported columns set to?

Data Type comes from the result of the statement, or String when it cannot be detected. Data Domain is Custom, the columns are never primary keys, and they inherit the table's permission groups.

Why can't I close the import window while an import runs?

Wait for Importing… to finish. The Dimension and Fact window cannot be closed while an import is running.

Do I have to save the columns right after importing?

Whenever you want to keep them: the imported rows are temporary until you click Apply. Revert discards them, so save when the grid looks right.