Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Custom Mapping" Display Value option is not available on tables with NULL entries #8116

Open
shawa opened this Issue Jul 20, 2018 · 5 comments

Comments

Projects
None yet
3 participants
@shawa
Copy link

shawa commented Jul 20, 2018

Expected behaviour: Custom value mappings should be available for all columns
Actual behaviour: Mappings only available for columns containing no null values

When choosing display values for Enum members, the "Custom Values" option only appears if there are no null entries in the column in question, even though Metabase can enumerate the members of the column for say, dropdowns in field filters.

Steps to reproduce:

  1. Create a table with a nullable column and populate with values, some null
  2. Navigate to Admin > Data Model > [Table] > [nullable column] > Settings gear
  3. Display Values
    • Only Use original value is available
  4. Remove any rows with nulls from the table
    • Custom Values is now available

I'm not overly familiar with the codebase, nor React, but this appears to be the line in question.

Info Value
Your Browser and the version Google Chrome 67.0.3396.99 (Official Build) (64-bit)
Your operating system OS X 10.13.5
Your databases Postgres
Metabase version v0.29.3
Metabase hosting environment Docker under Elastic Beanstalk
Metabase internal database Postgres
@zedidas

This comment has been minimized.

Copy link

zedidas commented Sep 4, 2018

We are implementing Metabase on a big database with a lot of historical data. Some of the fields did not exist previously so there are empty.

Due to the issue explained in this ticket, we are not able to use Custom Value Mapping in a lot of our columns. The work around appears to be to review the past data to eliminate any remaining null value but we would prefer to avoid changing any historical data.

Can we expect that this may be fixed in a future release? Is there any work around that would allow us to use custom mapping without having to change the data?

@zedidas

This comment has been minimized.

Copy link

zedidas commented Oct 16, 2018

Can someone provide an update on this. IMHO, it appears to be a fairly simple solution to implement, and that would extend the functionality available.

I would greatly appreciate some info on this. And also some info about any existing work-around.

Thanks!

@salsakran

This comment has been minimized.

Copy link
Contributor

salsakran commented Oct 31, 2018

When you remove null values does that change the field type?

Also, can you share the schema for that table and what field type Metabase guesses for that column?

@zedidas

This comment has been minimized.

Copy link

zedidas commented Oct 31, 2018

So I have made a very simple test. Here's a table I've created on MS SQL Express:

CREATE TABLE Products (
    id int,
    name varchar(255),
    type int,
    subtype int,
    PRIMARY KEY (id)
);

INSERT INTO Products VALUES (1,'Car', 1, 1);
INSERT INTO Products VALUES (2,'Plane', 1, 2);
INSERT INTO Products VALUES (3,'Bike', 1, 1);
INSERT INTO Products VALUES (4,'Boat', 1, NULL);
INSERT INTO Products VALUES (5,'Milk', 2, 4);
INSERT INTO Products VALUES (6,'Water', 2, 5);

As you can see, I am using two int columns for type and subtype. Column subtype will have a single entry which is NULL.

After I configure the database in the admin page, this is how the table looks:
image

Now if I try to configure Custom Mapping on the column Type, here's what I see:
image

If I try to do the same for the column Subtype, here's what I see:
image

As you can see, although both columns types are the same (int), since the column subtype has a NULL value, the Custom Mapping feature is not shown for that column.

This is a test I did: As soon as I update that NULL value as an int, the Custom Mapping option becomes available.

In my humble opinion, it would be interesting to allow custom mapping when the column contains NULL values. One could specify the Custom Mapping to apply to the NULL value itself.

Some final info:
Metabase version: v0.30.4
Database: SQL Server Express 2017 (but I've also seen this happening on Postgres)

Let me know if I can help with additional info.

@zedidas

This comment has been minimized.

Copy link

zedidas commented Dec 12, 2018

Hello,

Any chance this is going to be addressed in a future release? I am detecting more and more situations where the custom mapping is not possible only because there are a few entries with NULL values.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.