<commit_before>//===----------------------------------------------------------------------===//
//
//                         Peloton
//
//create_function_statement.h
//
// Identification: src/include/parser/create_function_statement.h
//
// Copyright (c) 2015-16, Carnegie Mellon University Database Group
//
//===----------------------------------------------------------------------===//

#pragma once

#include "expression/abstract_expression.h"
#include "type/types.h"
#include "common/sql_node_visitor.h"
#include "parser/sql_statement.h"

namespace peloton {
namespace parser {

struct Parameter {
  enum class FuncParamMode {
    FUNC_PARAM_IN = 'i',		/* input only */
    FUNC_PARAM_OUT = 'o',		/* output only */
    FUNC_PARAM_INOUT = 'b',		/* both */
    FUNC_PARAM_VARIADIC = 'v',	/* variadic (always input) */
    FUNC_PARAM_TABLE = 't'	
  };

  enum class DataType {
    INT,
    INTEGER,
    TINYINT,
    SMALLINT,
    BIGINT,
    VARCHAR,
    TEXT,
    BOOL,
    BOOLEAN
  };

  Parameter(DataType type): type(type) {};	

  virtual ~Parameter(){
    //delete name
    // delete type? 	 		
  }	

  DataType type; 
  FuncParamMode mode;

  static type::TypeId GetValueType(DataType type) {
    switch (type) {
      case DataType::INT:
      case DataType::INTEGER:
        return type::TypeId::INTEGER;
        break;
      case DataType::TINYINT:
        return type::TypeId::TINYINT;
        break;
      case DataType::SMALLINT:
        return type::TypeId::SMALLINT;
        break;
      case DataType::BIGINT:
        return type::TypeId::BIGINT;
        break;
      case DataType::TEXT:
      case DataType::VARCHAR:
        return type::TypeId::VARCHAR;
        break;
      case DataType::BOOL:
      case DataType::BOOLEAN:
        return type::TypeId::BOOLEAN;
        break;
      default:
        return type::TypeId::INVALID;
        break;
    }
  }	
};

struct ReturnType : Parameter { 
  ReturnType(DataType type):Parameter(type){};
  virtual ~ReturnType(){}
};

struct FuncParameter : Parameter {
  std::string name;
  FuncParameter(std::string name, DataType type):Parameter(type),name(name){};
  virtual ~FuncParameter(){}
};

//might want to change it to char* instead of string
struct CreateFunctionStatement : public SQLStatement {
  enum class ASclause {
    EXECUTABLE=0,
    QUERY_STRING=1	  	<commit_msg>Added new datatypes and cleaned existing code.<commit_after>//===----------------------------------------------------------------------===//
//
//                         Peloton
//
//create_function_statement.h
//
// Identification: src/include/parser/create_function_statement.h
//
// Copyright (c) 2015-16, Carnegie Mellon University Database Group
//
//===----------------------------------------------------------------------===//

#pragma once

#include "expression/abstract_expression.h"
#include "type/types.h"
#include "common/sql_node_visitor.h"
#include "parser/sql_statement.h"

namespace peloton {
namespace parser {

struct Parameter {
  enum class FuncParamMode {
    FUNC_PARAM_IN = 'i',		/* input only */
    FUNC_PARAM_OUT = 'o',		/* output only */
    FUNC_PARAM_INOUT = 'b',		/* both */
    FUNC_PARAM_VARIADIC = 'v',	/* variadic (always input) */
    FUNC_PARAM_TABLE = 't'	
  };

  enum class DataType {
    INT,
    INTEGER,
    TINYINT,
    SMALLINT,
    BIGINT,
    CHAR,
    DOUBLE,
    FLOAT,
    DECIMAL,
    VARCHAR,
    TEXT,
    BOOL,
    BOOLEAN
  };

  Parameter(DataType type): type(type) {};	

  virtual ~Parameter(){
    //delete name
    // delete type? 	 		
  }	

  DataType type; 
  FuncParamMode mode;

  static type::TypeId GetValueType(DataType type) {
    switch (type) {
      case DataType::INT:
      case DataType::INTEGER:
        return type::TypeId::INTEGER;
      case DataType::TINYINT:
        return type::TypeId::TINYINT;
      case DataType::SMALLINT:
        return type::TypeId::SMALLINT;
      case DataType::BIGINT:
        return type::TypeId::BIGINT;

      case DataType::DECIMAL:
      case DataType::DOUBLE:
      case DataType::FLOAT:
        return type::TypeId::DECIMAL;

      case DataType::CHAR:
      case DataType::TEXT:
      case DataType::VARCHAR:
        return type::TypeId::VARCHAR;

      case DataType::BOOL:
      case DataType::BOOLEAN:
        return type::TypeId::BOOLEAN;
      default:
        return type::TypeId::INVALID;
    }
  }	
};

struct ReturnType : Parameter { 
  ReturnType(DataType type):Parameter(type){};
  virtual ~ReturnType(){}
};

struct FuncParameter : Parameter {
  std::string name;
  FuncParameter(std::string name, DataType type):Parameter(type),name(name){};
  virtual ~FuncParameter(){}
};

//might want to change it to char* instead of string
class CreateFunctionStatement : public SQLStatement {
public:
  enum class ASclause {
    EXECUTABLE=0,
    QUERY_STRING=1	  	
{'fraction_non_alphanumeric': 0.17729908864954433, 'fraction_numerical': 0.0033140016570008283, 'mean_word_length': 2.251851851851852, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6263206', 'n_tokens_mistral': 1536, 'n_tokens_neox': 1478, 'n_words': 330}