code: def query_df_with_type_infer_fallback(
      query_str: str, dataframes: dict
  ):
      """Duckdb need to infer column types if column.dtype == object. By default it take 1000 rows,
      but that may be not sufficient for some cases. This func try to run query multiple times
      increasing butch size for type infer
  
      Args:
          query_str (str): query to execute
          dataframes (dict): dataframes
  
      Returns:
          pandas.DataFrame
          pandas.columns
      """
  
      for name, value in dataframes.items():
          locals()[name] = value
  
      con = duckdb.connect(database=":memory:")
      for sample_size in [1000, 10000, 1000000]:
          try:
              con.execute(
                  f"set global pandas_analyze_sample={sample_size};"
              )
              result_df = con.execute(query_str).fetchdf()
          except InvalidInputException:
              pass
          else:
              break
      else:
          raise InvalidInputException
      description = con.description
      con.close()
  
      return result_df, description
  
file_path: mindsdb/mindsdb/api/executor/utilities/sql.py
imports: import copy
  import duckdb
  from duckdb import InvalidInputException
  import numpy
  from mindsdb_sql import parse_sql
  from mindsdb_sql.render.sqlalchemy_render import SqlalchemyRender
  from mindsdb_sql.planner.utils import query_traversal
  from mindsdb_sql.parser.ast import Select, Identifier, Function, Constant
  from mindsdb.utilities import log
  from mindsdb.utilities.json_encoder import CustomJSONEncoder
label_desc: Use image node_id 1 for calling a global function with example usage: query_df_with_type_infer_fallback(query_str, dataframes) and returns: result_df,  description