Type casting in preview table in DataSpell when SQL query is output

I can't understand why Dataspell converts a text column to the integer type. I looked at the ddl table schema and there is a varchar type. But for some reason the integer type is displayed in the preview and statistics are provided for it. How can I explicitly prohibit this from happening in the settings?

SELECT DISTINCT CAST(year_ AS VARCHAR(4)), fid_hash
FROM mat_view.fns_2022_ind_metrics_by_fid_for_power_bi
LIMIT 100

I tried to find settings to prevent this from happening, but I couldn't.

 

0
Hi,
Please try upgrading IDE to the latest version, disabling all non-bundled plugins (**Settings | Plugins**, click the cog icon -> Disable All Downloaded Plugins) and check if the problem persists.
If the problem remains unresolved, we would like to investigate it properly. Please create an issue on YouTrack (https://youtrack.jetbrains.com/newIssue) regarding this problem. Attach relevant logs (Help | Collect Logs and Diagnostic Data), screenshots, precise steps for reproducing the issue and a runnable code/project sample if needed.
For urgent inquiries, please use Help | Contact Support in the IDE.
0

Hi,
Please try upgrading IDE to the latest version, disabling all non-bundled plugins (**Settings | Plugins**, click the cog icon -> Disable All Downloaded Plugins) and check if the problem persists.
If the problem remains unresolved, we would like to investigate it properly. Please create an issue on YouTrack (https://youtrack.jetbrains.com/newIssue solitaired ) regarding this problem. Attach relevant logs (Help | Collect Logs and Diagnostic Data), screenshots, precise steps for reproducing the issue and a runnable code/project sample if needed.
For urgent inquiries, please use Help | Contact Support in the IDE.

Thank you for sharing

0

You can’t prohibit it—DataSpell auto-inferrs column types for previews/statistics regardless of DDL or CAST, and there is currently no setting to disable this behavior.

 

0

That’s expected behavior. Data Spell automatically infers column types for data previews and statistics based on sampled values, not strictly on DDL or explicit CASTs, and currently there’s no setting to disable or override this inference. The underlying query result is still correct; it’s only the preview/analysis layer doing the auto-detection.

0

I’ve run into the same issue in Dataspell before. It looks like the IDE tries to infer data types based on the actual values it sees, which can cause a text column with numeric strings to be displayed as integers in the preview. One workaround is to explicitly set the column type when importing or connecting to the database, or check the data source settings to disable automatic type inference. Otherwise, it will keep trying to guess based on the content. geometry vibes

0

请先登录再写评论。