cube-js / cube

📊 Cube — The Semantic Layer for Building Data Applications
https://cube.dev
Other
17.54k stars 1.74k forks source link

Format time dimensions #2938

Closed viniciusrangelfp closed 1 week ago

viniciusrangelfp commented 3 years ago

Is your feature request related to a problem? Please describe. Cube could provide a date formatter, since we can throw the responsability of this to the database. I don't think cube should allow format any fields, because this will cause some performance issues and the api it's pretty fast, but since dates could be easily formated in the query maybe we can create somethig.

Describe the solution you'd like Add another property to time dimensions, including the property format, whatever this field it's used as dimensions we can check the property format from that particular time dimension. Maybe let this options be added to dimension it self, but just work for date times.

"timeDimensions": [
        {
            "dateRange": "Last 30 days",
            "dimension": "Route.route_date",
                        "format": "Y-m-d"
        }
    ]

or

"measures": [
        "Route.countRescuer",
                {measure: "Route.route_date",format:"Y-m-d"}
    ],

Additional context Slack link discussion https://cube-js.slack.com/archives/CC0403RRR/p1622747379065300

agnesesim commented 2 years ago

Same here

igorlukanin commented 1 week ago

I would argue that it's the responsibility of the application that consumes Cube's API to format values as needed. I believe this is the presentation logic and it should not be baked into the data model.