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":1005,"ttfb":270.09999990463257,"pageVisibility":"visible","entityId":97415,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"7aa3ef39-ddc0-4f76-a098-b1b02e780760","navigationType":0,"readyForUser":1116.4000000953674,"redirectCount":0,"resourceLoadedEnd":700.5999999046326,"resourceLoadedStart":277,"resourceTiming":[{"duration":52.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":277,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":277,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":329.5,"responseStart":0,"secureConnectionStart":0},{"duration":53.19999980926514,"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":277.2000002861023,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":277.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":330.40000009536743,"responseStart":0,"secureConnectionStart":0},{"duration":287.30000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":277.5,"connectEnd":277.5,"connectStart":277.5,"domainLookupEnd":277.5,"domainLookupStart":277.5,"fetchStart":277.5,"redirectEnd":0,"redirectStart":0,"requestStart":342.2000002861023,"responseEnd":564.8000001907349,"responseStart":366.30000019073486,"secureConnectionStart":277.5},{"duration":423,"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":277.59999990463257,"connectEnd":277.59999990463257,"connectStart":277.59999990463257,"domainLookupEnd":277.59999990463257,"domainLookupStart":277.59999990463257,"fetchStart":277.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":341.7000002861023,"responseEnd":700.5999999046326,"responseStart":364.80000019073486,"secureConnectionStart":277.59999990463257},{"duration":96.09999990463257,"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":277.80000019073486,"connectEnd":277.80000019073486,"connectStart":277.80000019073486,"domainLookupEnd":277.80000019073486,"domainLookupStart":277.80000019073486,"fetchStart":277.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":342.90000009536743,"responseEnd":373.90000009536743,"responseStart":368.30000019073486,"secureConnectionStart":277.80000019073486},{"duration":97.2000002861023,"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":278,"connectEnd":278,"connectStart":278,"domainLookupEnd":278,"domainLookupStart":278,"fetchStart":278,"redirectEnd":0,"redirectStart":0,"requestStart":343.7000002861023,"responseEnd":375.2000002861023,"responseStart":369.59999990463257,"secureConnectionStart":278},{"duration":96.7999997138977,"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":278.30000019073486,"connectEnd":278.30000019073486,"connectStart":278.30000019073486,"domainLookupEnd":278.30000019073486,"domainLookupStart":278.30000019073486,"fetchStart":278.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":343.40000009536743,"responseEnd":375.09999990463257,"responseStart":369.09999990463257,"secureConnectionStart":278.30000019073486},{"duration":58.5,"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":278.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":278.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":337,"responseStart":0,"secureConnectionStart":0},{"duration":96.69999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":278.7000002861023,"connectEnd":278.7000002861023,"connectStart":278.7000002861023,"domainLookupEnd":278.7000002861023,"domainLookupStart":278.7000002861023,"fetchStart":278.7000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":344.30000019073486,"responseEnd":375.40000009536743,"responseStart":369.90000009536743,"secureConnectionStart":278.7000002861023},{"duration":61.59999990463257,"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":278.80000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":278.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":340.40000009536743,"responseStart":0,"secureConnectionStart":0},{"duration":98,"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":279,"connectEnd":279,"connectStart":279,"domainLookupEnd":279,"domainLookupStart":279,"fetchStart":279,"redirectEnd":0,"redirectStart":0,"requestStart":344.7000002861023,"responseEnd":377,"responseStart":374.2000002861023,"secureConnectionStart":279},{"duration":363.5,"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":280.59999990463257,"connectEnd":280.59999990463257,"connectStart":280.59999990463257,"domainLookupEnd":280.59999990463257,"domainLookupStart":280.59999990463257,"fetchStart":280.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":366,"responseEnd":644.0999999046326,"responseStart":636.5,"secureConnectionStart":280.59999990463257},{"duration":365.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":280.80000019073486,"connectEnd":280.80000019073486,"connectStart":280.80000019073486,"domainLookupEnd":280.80000019073486,"domainLookupStart":280.80000019073486,"fetchStart":280.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":410.09999990463257,"responseEnd":646.3000001907349,"responseStart":641.7000002861023,"secureConnectionStart":280.80000019073486},{"duration":170.5,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":729.5999999046326,"connectEnd":729.5999999046326,"connectStart":729.5999999046326,"domainLookupEnd":729.5999999046326,"domainLookupStart":729.5999999046326,"fetchStart":729.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":861.0999999046326,"responseEnd":900.0999999046326,"responseStart":891,"secureConnectionStart":729.5999999046326},{"duration":239.30000019073486,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":995.0999999046326,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":995.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1234.4000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":255.59999990463257,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1005.4000000953674,"connectEnd":1005.4000000953674,"connectStart":1005.4000000953674,"domainLookupEnd":1005.4000000953674,"domainLookupStart":1005.4000000953674,"fetchStart":1005.4000000953674,"redirectEnd":0,"redirectStart":0,"requestStart":1230.2000002861023,"responseEnd":1261,"responseStart":1260.3000001907349,"secureConnectionStart":1005.4000000953674}],"fetchStart":1,"domainLookupStart":1,"domainLookupEnd":1,"connectStart":1,"connectEnd":1,"requestStart":41,"responseStart":271,"responseEnd":275,"domLoading":274,"domInteractive":1235,"domContentLoadedEventStart":1235,"domContentLoadedEventEnd":1286,"domComplete":1675,"loadEventStart":1675,"loadEventEnd":1675,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1206.2000002861023},{"name":"bigPipe.sidebar-id.end","time":1207},{"name":"bigPipe.activity-panel-pipe-id.start","time":1207.3000001907349},{"name":"bigPipe.activity-panel-pipe-id.end","time":1208.9000000953674},{"name":"activityTabFullyLoaded","time":1310.0999999046326}],"measures":[],"correlationId":"bc6ff630ae7f95","effectiveType":"4g","downlink":9,"rtt":0,"serverDuration":155,"dbReadsTimeInMs":51,"dbConnsTimeInMs":63,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}