Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-25015

Custom formatting of strings in MariaDB queries

Details

    Description

      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.

      Attachments

        Issue Links

          Activity

            robertbindar Robert Bindar created issue -
            robertbindar Robert Bindar made changes -
            Field Original Value New Value
            Description 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, which would leverage the fact that the server already know the datatype of each field used in the formatting scheme:

            SELECT sformat('arg1: {}, arg2: {}', col1, col2) from table;

            Also this one has the advantage of being able to pass 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.
            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, which would leverage the fact that the server already know the datatype of each field used in the formatting scheme:

            SELECT sformat('arg1: {}, arg2: {}', col1, col2) from table;

            Also this one has the advantage of being able to pass 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.
            robertbindar Robert Bindar made changes -
            Description 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, which would leverage the fact that the server already know the datatype of each field used in the formatting scheme:

            SELECT sformat('arg1: {}, arg2: {}', col1, col2) from table;

            Also this one has the advantage of being able to pass 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.
            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:

            {code:sql}SELECT printf('%s %s %s', first_name, last_name, job_title) from employees;{code}

            But it doesn't necessarily need to look this way, an alternative syntax could be, which would leverage the fact that the server already know the datatype of each field used in the formatting scheme:

            SELECT sformat('arg1: {}, arg2: {}', col1, col2) from table;

            Also this one has the advantage of being able to pass 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.
            robertbindar Robert Bindar made changes -
            Description 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:

            {code:sql}SELECT printf('%s %s %s', first_name, last_name, job_title) from employees;{code}

            But it doesn't necessarily need to look this way, an alternative syntax could be, which would leverage the fact that the server already know the datatype of each field used in the formatting scheme:

            SELECT sformat('arg1: {}, arg2: {}', col1, col2) from table;

            Also this one has the advantage of being able to pass 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.
            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:

            {code:sql}SELECT printf('%s %s %s', first_name, last_name, job_title) from employees;{code}

            But it doesn't necessarily need to look this way, an alternative syntax could be, which would leverage the fact that the server already know the datatype of each field used in the formatting scheme:

            {code:sql}SELECT sformat('arg1: {}, arg2: {}', col1, col2) from table;{code}

            Also this one has the advantage of being able to pass formatting options within the curly braces:
            {code:sql}
            # 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;
            {code}

            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.
            robertbindar Robert Bindar made changes -
            Description 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:

            {code:sql}SELECT printf('%s %s %s', first_name, last_name, job_title) from employees;{code}

            But it doesn't necessarily need to look this way, an alternative syntax could be, which would leverage the fact that the server already know the datatype of each field used in the formatting scheme:

            {code:sql}SELECT sformat('arg1: {}, arg2: {}', col1, col2) from table;{code}

            Also this one has the advantage of being able to pass formatting options within the curly braces:
            {code:sql}
            # 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;
            {code}

            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.
            Formatting more complex strings in a SELECT statement can get awkward when there are many {noformat}concat(){noformat}, {noformat}format(){noformat}, 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:

            {code:sql}SELECT printf('%s %s %s', first_name, last_name, job_title) from employees;{code}

            But it doesn't necessarily need to look this way, an alternative syntax could be, which would leverage the fact that the server already know the datatype of each field used in the formatting scheme:

            {code:sql}SELECT sformat('arg1: {}, arg2: {}', col1, col2) from table;{code}

            Also this one has the advantage of being able to pass formatting options within the curly braces:
            {code:sql}
            # 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;
            {code}

            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.
            robertbindar Robert Bindar made changes -
            Description Formatting more complex strings in a SELECT statement can get awkward when there are many {noformat}concat(){noformat}, {noformat}format(){noformat}, 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:

            {code:sql}SELECT printf('%s %s %s', first_name, last_name, job_title) from employees;{code}

            But it doesn't necessarily need to look this way, an alternative syntax could be, which would leverage the fact that the server already know the datatype of each field used in the formatting scheme:

            {code:sql}SELECT sformat('arg1: {}, arg2: {}', col1, col2) from table;{code}

            Also this one has the advantage of being able to pass formatting options within the curly braces:
            {code:sql}
            # 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;
            {code}

            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.
            Formatting more complex strings in a SELECT statement can get awkward when there are many {{monospaced}}concat(){{monospaced}}, {{monospaced}}format(){{monospaced}}, 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:

            {code:sql}SELECT printf('%s %s %s', first_name, last_name, job_title) from employees;{code}

            But it doesn't necessarily need to look this way, an alternative syntax could be, which would leverage the fact that the server already know the datatype of each field used in the formatting scheme:

            {code:sql}SELECT sformat('arg1: {}, arg2: {}', col1, col2) from table;{code}

            Also this one has the advantage of being able to pass formatting options within the curly braces:
            {code:sql}
            # 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;
            {code}

            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.
            robertbindar Robert Bindar made changes -
            Description Formatting more complex strings in a SELECT statement can get awkward when there are many {{monospaced}}concat(){{monospaced}}, {{monospaced}}format(){{monospaced}}, 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:

            {code:sql}SELECT printf('%s %s %s', first_name, last_name, job_title) from employees;{code}

            But it doesn't necessarily need to look this way, an alternative syntax could be, which would leverage the fact that the server already know the datatype of each field used in the formatting scheme:

            {code:sql}SELECT sformat('arg1: {}, arg2: {}', col1, col2) from table;{code}

            Also this one has the advantage of being able to pass formatting options within the curly braces:
            {code:sql}
            # 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;
            {code}

            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.
            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:

            {code:sql}SELECT printf('%s %s %s', first_name, last_name, job_title) from employees;{code}

            But it doesn't necessarily need to look this way, an alternative syntax could be, which would leverage the fact that the server already know the datatype of each field used in the formatting scheme:

            {code:sql}SELECT sformat('arg1: {}, arg2: {}', col1, col2) from table;{code}

            Also this one has the advantage of being able to pass formatting options within the curly braces:
            {code:sql}
            # 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;
            {code}

            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.
            robertbindar Robert Bindar made changes -
            Description 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:

            {code:sql}SELECT printf('%s %s %s', first_name, last_name, job_title) from employees;{code}

            But it doesn't necessarily need to look this way, an alternative syntax could be, which would leverage the fact that the server already know the datatype of each field used in the formatting scheme:

            {code:sql}SELECT sformat('arg1: {}, arg2: {}', col1, col2) from table;{code}

            Also this one has the advantage of being able to pass formatting options within the curly braces:
            {code:sql}
            # 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;
            {code}

            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.
            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:

            {code:sql}SELECT printf('%s %s %s', first_name, last_name, job_title) from employees;{code}

            But it doesn't necessarily need to look this way, an alternative syntax could be, which would leverage the fact that the server already know the datatype of each field used in the formatting scheme:

            {code:sql}SELECT sformat('arg1: {}, arg2: {}', col1, col2) from table;{code}

            Also this one has the advantage of being able to pass formatting options within the curly braces:
            {code:sql}
            # 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;
            {code}

            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.
            serg Sergei Golubchik made changes -
            Description 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:

            {code:sql}SELECT printf('%s %s %s', first_name, last_name, job_title) from employees;{code}

            But it doesn't necessarily need to look this way, an alternative syntax could be, which would leverage the fact that the server already know the datatype of each field used in the formatting scheme:

            {code:sql}SELECT sformat('arg1: {}, arg2: {}', col1, col2) from table;{code}

            Also this one has the advantage of being able to pass formatting options within the curly braces:
            {code:sql}
            # 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;
            {code}

            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.
            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:

            {code:sql}SELECT printf('%s %s, %s', first_name, last_name, job_title) from employees;{code}

            But it doesn't necessarily need to look this way, an alternative syntax could be, which would leverage the fact that the server already know the datatype of each field used in the formatting scheme:

            {code:sql}SELECT sformat('arg1: {}, arg2: {}', col1, col2) from table;{code}

            Also this one has the advantage of being able to pass formatting options within the curly braces:
            {code:sql}
            # 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;
            {code}

            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.
            serg Sergei Golubchik made changes -
            Description 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:

            {code:sql}SELECT printf('%s %s, %s', first_name, last_name, job_title) from employees;{code}

            But it doesn't necessarily need to look this way, an alternative syntax could be, which would leverage the fact that the server already know the datatype of each field used in the formatting scheme:

            {code:sql}SELECT sformat('arg1: {}, arg2: {}', col1, col2) from table;{code}

            Also this one has the advantage of being able to pass formatting options within the curly braces:
            {code:sql}
            # 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;
            {code}

            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.
            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:

            {code:sql}SELECT printf('%s %s, %s', first_name, last_name, job_title) from employees;{code}

            But it doesn't necessarily need to look this way, an alternative syntax could be, which would leverage the fact that the server already know the datatype of each field used in the formatting scheme:

            {code:sql}SELECT sformat('arg1: {}, arg2: {}', col1, col2) from table;{code}

            Also this one has the advantage of being able to pass formatting options within the curly braces:
            {code:sql}
            -- 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;
            {code}

            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.
            serg Sergei Golubchik made changes -
            Description 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:

            {code:sql}SELECT printf('%s %s, %s', first_name, last_name, job_title) from employees;{code}

            But it doesn't necessarily need to look this way, an alternative syntax could be, which would leverage the fact that the server already know the datatype of each field used in the formatting scheme:

            {code:sql}SELECT sformat('arg1: {}, arg2: {}', col1, col2) from table;{code}

            Also this one has the advantage of being able to pass formatting options within the curly braces:
            {code:sql}
            -- 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;
            {code}

            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.
            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:

            {code:sql}SELECT printf('%s %s, %s', first_name, last_name, job_title) from employees;{code}

            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 know the datatype of each field used in the formatting scheme:

            {code:sql}SELECT sformat('arg1: {}, arg2: {}', col1, col2) from table;{code}
            In that syntax one passes formatting options within the curly braces:
            {code:sql}
            -- 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;
            {code}

            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.
            robertbindar Robert Bindar made changes -
            Fix Version/s 10.7 [ 24805 ]
            Fix Version/s 10.6 [ 24028 ]
            serg Sergei Golubchik made changes -
            Description 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:

            {code:sql}SELECT printf('%s %s, %s', first_name, last_name, job_title) from employees;{code}

            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 know the datatype of each field used in the formatting scheme:

            {code:sql}SELECT sformat('arg1: {}, arg2: {}', col1, col2) from table;{code}
            In that syntax one passes formatting options within the curly braces:
            {code:sql}
            -- 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;
            {code}

            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.
            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:

            {code:sql}SELECT printf('%s %s, %s', first_name, last_name, job_title) from employees;{code}

            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:

            {code:sql}SELECT sformat('arg1: {}, arg2: {}', col1, col2) from table;{code}
            In that syntax one passes formatting options within the curly braces:
            {code:sql}
            -- 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;
            {code}

            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.
            cvicentiu Vicențiu Ciorbaru made changes -
            Assignee Robert Bindar [ robertbindar ] Vicențiu Ciorbaru [ cvicentiu ]
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            Priority Minor [ 4 ] Critical [ 2 ]
            serg Sergei Golubchik made changes -
            Assignee Vicențiu Ciorbaru [ cvicentiu ] Sergei Golubchik [ serg ]
            serg Sergei Golubchik made changes -
            Status Open [ 1 ] Confirmed [ 10101 ]
            serg Sergei Golubchik made changes -
            Status Confirmed [ 10101 ] In Review [ 10002 ]
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            Assignee Sergei Golubchik [ serg ] Elena Stepanova [ elenst ]
            Status In Review [ 10002 ] Stalled [ 10000 ]
            serg Sergei Golubchik made changes -
            Roel Roel Van de Paar made changes -
            Assignee Elena Stepanova [ elenst ] Roel Van de Paar [ roel ]
            Roel Roel Van de Paar made changes -
            Status Stalled [ 10000 ] In Progress [ 3 ]
            Roel Roel Van de Paar made changes -
            Status In Progress [ 3 ] Stalled [ 10000 ]
            Roel Roel Van de Paar made changes -
            Assignee Roel Van de Paar [ roel ] Sergei Golubchik [ serg ]
            serg Sergei Golubchik made changes -
            Assignee Sergei Golubchik [ serg ] Roel Van de Paar [ roel ]
            Roel Roel Van de Paar made changes -
            Roel Roel Van de Paar made changes -
            Roel Roel Van de Paar made changes -
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            Roel Roel Van de Paar made changes -
            Roel Roel Van de Paar made changes -
            Assignee Roel Van de Paar [ roel ] Sergei Golubchik [ serg ]
            serg Sergei Golubchik made changes -
            Fix Version/s 10.7.1 [ 26120 ]
            Fix Version/s 10.7 [ 24805 ]
            Resolution Fixed [ 1 ]
            Status Stalled [ 10000 ] Closed [ 6 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 119616 ] MariaDB v4 [ 134400 ]
            ralf.gebhardt Ralf Gebhardt made changes -
            Labels gsoc21 Preview_10.7 gsoc21
            elenst Elena Stepanova made changes -

            People

              serg Sergei Golubchik
              robertbindar Robert Bindar
              Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.