prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Result of query with same column names with return different column names
  Issue exists for any 'internal' tables. If query multiple columns with same name:
  ```
  select 1 as "a", 1 as "a" from information_schema.tables limit 1;
  ```
  then result will be:
  ```
  +------+------+
  | a    | a_2  |
  +------+------+
  | 1    | 1    |
  +------+------+
  ```
  
  </issue>
  <code>
  [start of mindsdb/api/mysql/mysql_proxy/utilities/sql.py]
  1 import duckdb
  2 import numpy as np
  3 from mindsdb_sql import parse_sql
  4 from mindsdb_sql.parser.ast import Select, Identifier, BinaryOperation, OrderBy
  5 from mindsdb_sql.render.sqlalchemy_render import SqlalchemyRender
  6 
  7 from mindsdb.utilities.log import log
  8 
  9 
  10 def _remove_table_name(root):
  11     if isinstance(root, BinaryOperation):
  12         _remove_table_name(root.args[0])
  13         _remove_table_name(root.args[1])
  14     elif isinstance(root, Identifier):
  15         root.parts = [root.parts[-1]]
  16 
  17 
  18 def query_df(df, query):
  19     """ Perform simple query ('select' from one table, without subqueries and joins) on DataFrame.
  20 
  21         Args:
  22             df (pandas.DataFrame): data
  23             query (mindsdb_sql.parser.ast.Select | str): select query
  24 
  25         Returns:
  26             pandas.DataFrame
  27     """
  28 
  29     if isinstance(query, str):
  30         query_ast = parse_sql(query, dialect='mysql')
  31     else:
  32         query_ast = query
  33 
  34     if isinstance(query_ast, Select) is False or isinstance(query_ast.from_table, Identifier) is False:
  35         raise Exception("Only 'SELECT from TABLE' statements supported for internal query")
  36 
  37     query_ast.from_table.parts = ['df_table']
  38     for identifier in query_ast.targets:
  39         if isinstance(identifier, Identifier):
  40             identifier.parts = [identifier.parts[-1]]
  41     if isinstance(query_ast.order_by, list):
  42         for orderby in query_ast.order_by:
  43             if isinstance(orderby, OrderBy) and isinstance(orderby.field, Identifier):
  44                 orderby.field.parts = [orderby.field.parts[-1]]
  45     _remove_table_name(query_ast.where)
  46 
  47     render = SqlalchemyRender('postgres')
  48     try:
  49         query_str = render.get_string(query_ast, with_failback=False)
  50     except Exception as e:
  51         log.error(f"Exception during query casting to 'postgres' dialect. Query: {str(query)}. Error: {e}")
  52         query_str = render.get_string(query_ast, with_failback=True)
  53 
  54     res = duckdb.query_df(df, 'df_table', query_str)
  55     result_df = res.df()
  56     result_df = result_df.replace({np.nan: None})
  57     return result_df
  58
  [end of mindsdb/api/mysql/mysql_proxy/utilities/sql.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/mindsdb/api/mysql/mysql_proxy/utilities/sql.py b/mindsdb/api/mysql/mysql_proxy/utilities/sql.py
  --- a/mindsdb/api/mysql/mysql_proxy/utilities/sql.py
  +++ b/mindsdb/api/mysql/mysql_proxy/utilities/sql.py
  @@ -54,4 +54,13 @@
       res = duckdb.query_df(df, 'df_table', query_str)
       result_df = res.df()
       result_df = result_df.replace({np.nan: None})
  +
  +    new_column_names = {}
  +    real_column_names = [x[0] for x in res.description()]
  +    for i, duck_column_name in enumerate(result_df.columns):
  +        new_column_names[duck_column_name] = real_column_names[i]
  +    result_df = result_df.rename(
  +        new_column_names,
  +        axis='columns'
  +    )
       return result_df
  
verification_info: {"golden_diff": "diff --git a/mindsdb/api/mysql/mysql_proxy/utilities/sql.py b/mindsdb/api/mysql/mysql_proxy/utilities/sql.py\n--- a/mindsdb/api/mysql/mysql_proxy/utilities/sql.py\n+++ b/mindsdb/api/mysql/mysql_proxy/utilities/sql.py\n@@ -54,4 +54,13 @@\n     res = duckdb.query_df(df, 'df_table', query_str)\n     result_df = res.df()\n     result_df = result_df.replace({np.nan: None})\n+\n+    new_column_names = {}\n+    real_column_names = [x[0] for x in res.description()]\n+    for i, duck_column_name in enumerate(result_df.columns):\n+        new_column_names[duck_column_name] = real_column_names[i]\n+    result_df = result_df.rename(\n+        new_column_names,\n+        axis='columns'\n+    )\n     return result_df\n", "issue": "Result of query with same column names with return different column names\nIssue exists for any 'internal' tables. If query multiple columns with same name:\r\n```\r\nselect 1 as \"a\", 1 as \"a\" from information_schema.tables limit 1;\r\n```\r\nthen result will be:\r\n```\r\n+------+------+\r\n| a    | a_2  |\r\n+------+------+\r\n| 1    | 1    |\r\n+------+------+\r\n```\n", "before_files": [{"content": "import duckdb\nimport numpy as np\nfrom mindsdb_sql import parse_sql\nfrom mindsdb_sql.parser.ast import Select, Identifier, BinaryOperation, OrderBy\nfrom mindsdb_sql.render.sqlalchemy_render import SqlalchemyRender\n\nfrom mindsdb.utilities.log import log\n\n\ndef _remove_table_name(root):\n    if isinstance(root, BinaryOperation):\n        _remove_table_name(root.args[0])\n        _remove_table_name(root.args[1])\n    elif isinstance(root, Identifier):\n        root.parts = [root.parts[-1]]\n\n\ndef query_df(df, query):\n    \"\"\" Perform simple query ('select' from one table, without subqueries and joins) on DataFrame.\n\n        Args:\n            df (pandas.DataFrame): data\n            query (mindsdb_sql.parser.ast.Select | str): select query\n\n        Returns:\n            pandas.DataFrame\n    \"\"\"\n\n    if isinstance(query, str):\n        query_ast = parse_sql(query, dialect='mysql')\n    else:\n        query_ast = query\n\n    if isinstance(query_ast, Select) is False or isinstance(query_ast.from_table, Identifier) is False:\n        raise Exception(\"Only 'SELECT from TABLE' statements supported for internal query\")\n\n    query_ast.from_table.parts = ['df_table']\n    for identifier in query_ast.targets:\n        if isinstance(identifier, Identifier):\n            identifier.parts = [identifier.parts[-1]]\n    if isinstance(query_ast.order_by, list):\n        for orderby in query_ast.order_by:\n            if isinstance(orderby, OrderBy) and isinstance(orderby.field, Identifier):\n                orderby.field.parts = [orderby.field.parts[-1]]\n    _remove_table_name(query_ast.where)\n\n    render = SqlalchemyRender('postgres')\n    try:\n        query_str = render.get_string(query_ast, with_failback=False)\n    except Exception as e:\n        log.error(f\"Exception during query casting to 'postgres' dialect. Query: {str(query)}. Error: {e}\")\n        query_str = render.get_string(query_ast, with_failback=True)\n\n    res = duckdb.query_df(df, 'df_table', query_str)\n    result_df = res.df()\n    result_df = result_df.replace({np.nan: None})\n    return result_df\n", "path": "mindsdb/api/mysql/mysql_proxy/utilities/sql.py"}]}