Type:
Task
Priority:
Critical
Resolution:
Fixed
Formatting more complex strings in a SELECT statement can get awkward when there are many concat() , format() , etc calls involved.
It would be very cool and helpful to have a function that takes an input string and a formatting specification and returns string formatted using the rules the user passed in the specification.
A great example for such a function is the classic C printf function, which, in this context, would look something like:
SELECT printf( '%s %s, %s' , first_name, last_name, job_title) from employees;
But it doesn't necessarily need to look this way, an alternative syntax could be Python-ish, which would leverage the fact that the server already knows the datatype of each field used in the formatting scheme:
SELECT sformat( 'arg1: {}, arg2: {}' , col1, col2) from table ;
In that syntax one passes formatting options within the curly braces:
-- Print 'arg1: col1, arg2: col2' where col1 from table is of datetime type and should be printed as: 'Sunday November 2021'
SELECT sformat( 'arg1: {%W %M %Y}, arg2: {}' , col1, col2) from table ;
Ideally, this new function should use, behind the scenes, the existing builtin formatting functions in MariaDB (e.g. date_format() , format() ) and even future formatting functions (e.g. MySQL's format_bytes() , format_pico_time() ), so the syntax has to be designed in a smart way to accommodate easily future additions.
{"report":{"fcp":1697.4000000953674,"ttfb":183.80000019073486,"pageVisibility":"visible","entityId":97415,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"69e40dc6-7bad-4859-b885-740bd4a42ca2","navigationType":0,"readyForUser":1873.5999999046326,"redirectCount":0,"resourceLoadedEnd":1792.5999999046326,"resourceLoadedStart":195.09999990463257,"resourceTiming":[{"duration":289,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":195.09999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":195.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":484.09999990463257,"responseStart":0,"secureConnectionStart":0},{"duration":533.1999998092651,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":195.40000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":195.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":728.5999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":542.5999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":195.59999990463257,"connectEnd":195.59999990463257,"connectStart":195.59999990463257,"domainLookupEnd":195.59999990463257,"domainLookupStart":195.59999990463257,"fetchStart":195.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":195.59999990463257,"responseEnd":738.1999998092651,"responseStart":738.1999998092651,"secureConnectionStart":195.59999990463257},{"duration":677.5999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":195.80000019073486,"connectEnd":195.80000019073486,"connectStart":195.80000019073486,"domainLookupEnd":195.80000019073486,"domainLookupStart":195.80000019073486,"fetchStart":195.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":195.80000019073486,"responseEnd":873.4000000953674,"responseStart":873.4000000953674,"secureConnectionStart":195.80000019073486},{"duration":702.9000000953674,"initiatorType":"script","name":"https://jira.mariadb.org/s/a9324d6758d385eb45c462685ad88f1d-CDN/lu2cib/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":195.90000009536743,"connectEnd":195.90000009536743,"connectStart":195.90000009536743,"domainLookupEnd":195.90000009536743,"domainLookupStart":195.90000009536743,"fetchStart":195.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":195.90000009536743,"responseEnd":898.8000001907349,"responseStart":898.8000001907349,"secureConnectionStart":195.90000009536743},{"duration":734.3000001907349,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":196.19999980926514,"connectEnd":196.19999980926514,"connectStart":196.19999980926514,"domainLookupEnd":196.19999980926514,"domainLookupStart":196.19999980926514,"fetchStart":196.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":196.19999980926514,"responseEnd":930.5,"responseStart":930.5,"secureConnectionStart":196.19999980926514},{"duration":738,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":196.40000009536743,"connectEnd":196.40000009536743,"connectStart":196.40000009536743,"domainLookupEnd":196.40000009536743,"domainLookupStart":196.40000009536743,"fetchStart":196.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":196.40000009536743,"responseEnd":934.4000000953674,"responseStart":934.4000000953674,"secureConnectionStart":196.40000009536743},{"duration":917.5999999046326,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2cib/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":196.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":196.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1114.0999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":738.6000003814697,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":196.69999980926514,"connectEnd":196.69999980926514,"connectStart":196.69999980926514,"domainLookupEnd":196.69999980926514,"domainLookupStart":196.69999980926514,"fetchStart":196.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":196.69999980926514,"responseEnd":935.3000001907349,"responseStart":935.3000001907349,"secureConnectionStart":196.69999980926514},{"duration":919.0999999046326,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":196.90000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":196.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1116,"responseStart":0,"secureConnectionStart":0},{"duration":740,"initiatorType":"script","name":"https://jira.mariadb.org/s/5d5e8fe91fbc506585e83ea3b62ccc4b-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":197,"connectEnd":197,"connectStart":197,"domainLookupEnd":197,"domainLookupStart":197,"fetchStart":197,"redirectEnd":0,"redirectStart":0,"requestStart":197,"responseEnd":937,"responseStart":937,"secureConnectionStart":197},{"duration":976.0999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":380,"connectEnd":380,"connectStart":380,"domainLookupEnd":380,"domainLookupStart":380,"fetchStart":380,"redirectEnd":0,"redirectStart":0,"requestStart":380,"responseEnd":1356.0999999046326,"responseStart":1356.0999999046326,"secureConnectionStart":380},{"duration":1412.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":380.09999990463257,"connectEnd":380.09999990463257,"connectStart":380.09999990463257,"domainLookupEnd":380.09999990463257,"domainLookupStart":380.09999990463257,"fetchStart":380.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":380.09999990463257,"responseEnd":1792.5999999046326,"responseStart":1792.5999999046326,"secureConnectionStart":380.09999990463257},{"duration":446.30000019073486,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1200.5999999046326,"connectEnd":1200.5999999046326,"connectStart":1200.5999999046326,"domainLookupEnd":1200.5999999046326,"domainLookupStart":1200.5999999046326,"fetchStart":1200.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":1200.5999999046326,"responseEnd":1646.9000000953674,"responseStart":1646.9000000953674,"secureConnectionStart":1200.5999999046326},{"duration":501.09999990463257,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1491.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1491.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1992.5999999046326,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":13,"responseStart":184,"responseEnd":378,"domLoading":192,"domInteractive":2012,"domContentLoadedEventStart":2012,"domContentLoadedEventEnd":2062,"domComplete":3516,"loadEventStart":3516,"loadEventEnd":3520,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1998.6999998092651},{"name":"bigPipe.sidebar-id.end","time":1999.5999999046326},{"name":"bigPipe.activity-panel-pipe-id.start","time":1999.6999998092651},{"name":"bigPipe.activity-panel-pipe-id.end","time":2002.4000000953674},{"name":"activityTabFullyLoaded","time":2075.9000000953674}],"measures":[],"correlationId":"377286e74a8fa4","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":95,"dbReadsTimeInMs":15,"dbConnsTimeInMs":24,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}