nodes: 0, module; 1, function_definition; 2, function_name:_auto; 3, parameters; 4, block; 5, identifier:method; 6, identifier:fields; 7, identifier:count; 8, identifier:percent; 9, identifier:key_field; 10, identifier:ascending; 11, expression_statement; 12, if_statement; 13, comment:"""Construct a sampling function according to the provided sampling technique, provided all
      its needed fields are passed as arguments
  
      Args:
        method: one of the supported sampling methods: {limit,random,hashed,sorted}
        fields: an optional list of field names to retrieve.
        count: maximum number of rows to limit the sampled results to.
        percent: the percentage of the resulting hashes to select if using hashed sampling
        key_field: the name of the field to sort the rows by or use for hashing
        ascending: whether to sort in ascending direction or not.
      Returns:
        A sampling function using the provided arguments
      Raises:
        Exception if an unsupported mathod name is passed
      """; 14, comparison_operator:method == 'limit'; 15, block; 16, elif_clause; 17, elif_clause; 18, elif_clause; 19, else_clause; 20, identifier:method; 21, string; 22, return_statement; 23, comparison_operator:method == 'random'; 24, block; 25, comparison_operator:method == 'hashed'; 26, block; 27, comparison_operator:method == 'sorted'; 28, block; 29, block; 30, string_content:limit; 31, call; 32, identifier:method; 33, string; 34, return_statement; 35, identifier:method; 36, string; 37, return_statement; 38, identifier:method; 39, string; 40, return_statement; 41, raise_statement; 42, attribute; 43, argument_list; 44, string_content:random; 45, call; 46, string_content:hashed; 47, call; 48, string_content:sorted; 49, call; 50, call; 51, identifier:Sampling; 52, identifier:default; 53, keyword_argument; 54, keyword_argument; 55, attribute; 56, argument_list; 57, attribute; 58, argument_list; 59, attribute; 60, argument_list; 61, identifier:Exception; 62, argument_list; 63, identifier:fields; 64, identifier:fields; 65, identifier:count; 66, identifier:count; 67, identifier:Sampling; 68, identifier:random; 69, keyword_argument; 70, keyword_argument; 71, keyword_argument; 72, identifier:Sampling; 73, identifier:hashed; 74, keyword_argument; 75, keyword_argument; 76, keyword_argument; 77, keyword_argument; 78, identifier:Sampling; 79, identifier:sorted; 80, keyword_argument; 81, keyword_argument; 82, keyword_argument; 83, keyword_argument; 84, binary_operator:'Unsupported sampling method: %s' % method; 85, identifier:fields; 86, identifier:fields; 87, identifier:percent; 88, identifier:percent; 89, identifier:count; 90, identifier:count; 91, identifier:fields; 92, identifier:fields; 93, identifier:field_name; 94, identifier:key_field; 95, identifier:percent; 96, identifier:percent; 97, identifier:count; 98, identifier:count; 99, identifier:fields; 100, identifier:fields; 101, identifier:field_name; 102, identifier:key_field; 103, identifier:ascending; 104, identifier:ascending; 105, identifier:count; 106, identifier:count; 107, string; 108, identifier:method; 109, string_content:Unsupported sampling method: %s
code: def _auto(method, fields, count, percent, key_field, ascending):
      """Construct a sampling function according to the provided sampling technique, provided all
      its needed fields are passed as arguments
  
      Args:
        method: one of the supported sampling methods: {limit,random,hashed,sorted}
        fields: an optional list of field names to retrieve.
        count: maximum number of rows to limit the sampled results to.
        percent: the percentage of the resulting hashes to select if using hashed sampling
        key_field: the name of the field to sort the rows by or use for hashing
        ascending: whether to sort in ascending direction or not.
      Returns:
        A sampling function using the provided arguments
      Raises:
        Exception if an unsupported mathod name is passed
      """
      if method == 'limit':
        return Sampling.default(fields=fields, count=count)
      elif method == 'random':
        return Sampling.random(fields=fields, percent=percent, count=count)
      elif method == 'hashed':
        return Sampling.hashed(fields=fields, field_name=key_field, percent=percent, count=count)
      elif method == 'sorted':
        return Sampling.sorted(fields=fields, field_name=key_field, ascending=ascending, count=count)
      else:
        raise Exception('Unsupported sampling method: %s' % method)