






"""simple docstring"""


import sys
from dataclasses import dataclass
from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union

import pandas as pd
import pyarrow as pa

import datasets
import datasets.config
from datasets.features.features import require_storage_cast
from datasets.table import table_cast


if TYPE_CHECKING:
   import sqlitea

   import sqlalchemy


_UpperCamelCase							:       str       					=		datasets.utils.logging.get_logger(__name__)






@dataclass
class 		snake_case    (    datasets.BuilderConfig			):
    __magic_name__       	=	None
    __magic_name__       	=	None
    __magic_name__       	=	None
    __magic_name__       	=	True
    __magic_name__       	=	None
    __magic_name__       	=	None
    __magic_name__       	=	None
    __magic_name__       	=	1_0000
    __magic_name__       	=	None





    def 							lowerCamelCase__ (				self      :   List[str]     ):


      '''simple docstring'''




      if self.sql is None:
        raise ValueError('sql must be specified'     )
      if self.con is None:
        raise ValueError('con must be specified'     )





    def 							lowerCamelCase__ (				self      :   int							,						A      :   dict							,						A      :   Optional[datasets.Features] = None							,						):


      '''simple docstring'''




      a	:     Any							=  config_kwargs.copy()
      # We need to stringify the Selectable object to make its hash deterministic

      # The process of stringifying is explained here: http://docs.sqlalchemy.org/en/latest/faq/sqlexpressions.html
      a	:     Optional[Any]							=  config_kwargs['sql']
      if not isinstance(A							,						A     ):
        if datasets.config.SQLALCHEMY_AVAILABLE and "sqlalchemy" in sys.modules:
          import sqlalchemy

          if isinstance(A							,						sqlalchemy.sql.Selectable     ):
            a	:     Any							=  sqlalchemy.create_engine(config_kwargs['con'].split('://'     )[0] + '://'     )
            a	:     str							=  str(sql.compile(dialect=engine.dialect     )     )
            a	:     Union[str, Any]							=  sql_str
          else:
            raise TypeError(
                F'''Supported types for \'sql\' are string and sqlalchemy.sql.Selectable but got {type(A     )}: {sql}'''     )
        else:
          raise TypeError(
              F'''Supported types for \'sql\' are string and sqlalchemy.sql.Selectable but got {type(A     )}: {sql}'''     )
      a	:     int							=  config_kwargs['con']
      if not isinstance(A							,						A     ):
        a	:     Optional[Any]							=  id(A     )
        logger.info(
            F'''SQL connection \'con\' of type {type(A     )} couldn\'t be hashed properly. To enable hashing, specify \'con\' as URI string instead.'''     )

      return super().create_config_id(A							,						custom_features=A     )





    @property
    def 							lowerCamelCase__ (				self      :   Dict     ):


      '''simple docstring'''




      a	:     Optional[Any]							=  {
          'index_col': self.index_col,
          'columns': self.columns,
          'params': self.params,
          'coerce_float': self.coerce_float,
          'parse_dates': self.parse_dates,
      }
      return pd_read_sql_kwargs






class 		snake_case    (    datasets.ArrowBasedBuilder			):
    __magic_name__       	=	SqlConfig





    def 							lowerCamelCase__ (				self      :   int     ):


      '''simple docstring'''




      return datasets.DatasetInfo(features=self.config.features     )





    def 							lowerCamelCase__ (				self      :   Any							,						A      :   Any     ):


      '''simple docstring'''




      return [datasets.SplitGenerator(name=datasets.Split.TRAIN							,						gen_kwargs={}     )]





    def 							lowerCamelCase__ (				self      :   Dict							,						A      :   pa.Table     ):


      '''simple docstring'''




      if self.config.features is not None:
        a	:     Dict							=  self.config.features.arrow_schema
        if all(not require_storage_cast(A     ) for feature in self.config.features.values()     ):
          # cheaper cast
          a	:     Optional[Any]							=  pa.Table.from_arrays([pa_table[field.name] for field in schema]							,						schema=A     )
        else:
          # more expensive cast; allows str <-> int/float or str to Audio for example
          a	:     List[str]							=  table_cast(A							,						A     )
      return pa_table





    def 							lowerCamelCase__ (				self      :   Any     ):


      '''simple docstring'''




      a	:     Optional[Any]							=  self.config.chunksize
      a	:     Optional[int]							=  pd.read_sql(
          self.config.sql							,						self.config.con							,						chunksize=A							,						**self.config.pd_read_sql_kwargs     )
      a	:     int							=  [sql_reader] if chunksize is None else sql_reader
      for chunk_idx, df in enumerate(A     ):
        a	:     List[Any]							=  pa.Table.from_pandas(A     )
        yield chunk_idx, self._cast_table(A     )












"""simple docstring"""


from doctest import testmod
from math import sqrt




def      snake_case    (A_ :int ):







  '''simple docstring'''

  a	:     list[int]							=  []
  if num < 1:
    return facs
  facs.append(1 )
  if num == 1:
    return facs
  facs.append(A_ )
  for i in range(2      ,     int(sqrt(A_ ) ) + 1 ):
    if num % i == 0:  # If i is a factor of num
      facs.append(A_ )
      a	:     Optional[Any]							=  num // i  # num//i is the other factor of num
      if d != i:  # If d and i are distinct
        facs.append(A_ )  # we have found another factor
  facs.sort()
  return facs


if __name__ == "__main__":
   testmod(name='factors_of_a_number', verbose=True)




