<commit_before>-- The MIT License (MIT) Copyright (c) 2017 <NAME>
-- NuoDB has functions and procedures
-- These links may help
-- http://doc.nuodb.com/Latest/Content/CREATE-FUNCTION.htm
-- http://doc.nuodb.com/Latest/Content/CREATE-PROCEDURE.htm

-- This should return the client culture state of the current connection or transaction
-- For now it just returns 1033,'en-US'
DROP FUNCTION IF EXISTS ClientCulture;

SET DELIMITER @
CREATE FUNCTION ClientCulture (
) RETURNS INTEGER AS
 RETURN (
 SELECT 1033
 FROM Dual
 );
END_FUNCTION;
@
SET DELIMITER ;

-- NuoDB does not have an interval type.
-- Will use an Integer in seconds instead.
-- Asume negative values for now
SET DELIMITER @
CREATE FUNCTION GetInterval(
 interval_value STRING
) RETURNS INTEGER AS
 RETURN (
  SELECT datediff(SECOND, '1970-01-01 ' || interval_value, '1970-01-01') FROM DUAL<commit_msg>Person view to NuoDB<commit_after>-- The MIT License (MIT) Copyright (c) 2017 <NAME>
-- NuoDB has functions and procedures
-- These links may help
-- http://doc.nuodb.com/Latest/Content/CREATE-FUNCTION.htm
-- http://doc.nuodb.com/Latest/Content/CREATE-PROCEDURE.htm

DROP FUNCTION IF EXISTS age;

SET DELIMITER @
CREATE FUNCTION age (
 asOf DATE,
 start DATE
) RETURNS STRING AS
 RETURN (
  SELECT CAST(DATEDIFF(YEAR, start, asOf) AS STRING) || ' years' FROM DUAL
 );
END_FUNCTION;
@
SET DELIMITER ;

SET DELIMITER @
CREATE FUNCTION age (
 start DATE
) RETURNS STRING AS
 RETURN (
  SELECT CAST(DATEDIFF(YEAR, start, NOW()) AS STRING) || ' years' FROM DUAL
 );
END_FUNCTION;
@
SET DELIMITER ;


DROP FUNCTION IF EXISTS birthday;

SET DELIMITER @
CREATE FUNCTION birthday (
 birth DATE,
 asOf DATE
) RETURNS STRING AS
 RETURN (
  SELECT
  CASE WHEN extract(month FROM birth) < extract(month FROM asOf) THEN
    (extract(year FROM asOf) + 1) || '-' ||  extract(month FROM birth) || '-' ||  extract(day FROM birth)
  ELSE
   CASE WHEN extract(month FROM birth) = extract(month FROM asOf)
     AND extract(day FROM birth) < extract(day FROM asOf) THEN
    (extract(year FROM asOf) + 1) || '-' ||  extract(month FROM birth) || '-' ||  extract(day FROM birth)
   ELSE
    extract(year FROM asOf) || '-' ||  extract(month FROM birth) || '-' ||  extract(day FROM birth)
   END
  END AS birthday
  FROM DUAL
 );
END_FUNCTION;
@
SET DELIMITER ;

SET DELIMITER @
CREATE FUNCTION birthday (
 birth DATE
) RETURNS STRING AS
 RETURN (
  SELECT birthday(birth, NOW()) FROM DUAL
 );
END_FUNCTION;
@
SET DELIMITER ;

DROP FUNCTION IF EXISTS days_until_birthday;

SET DELIMITER @
CREATE FUNCTION days_until_birthday (
 birth DATE,
 asOf DATE
) RETURNS INTEGER AS
 RETURN (
  SELECT DATEDIFF(DAY, asOf, birthday(birth)) FROM DUAL
 );
END_FUNCTION;
@
SET DELIMITER ;

-- This should return the client culture state of the current connection or transaction
-- For now it just returns 1033,'en-US'
DROP FUNCTION IF EXISTS ClientCulture;

SET DELIMITER @
CREATE FUNCTION ClientCulture (
) RETURNS INTEGER AS
 RETURN (
 SELECT 1033
 FROM Dual
 );
END_FUNCTION;
@
SET DELIMITER ;

-- NuoDB does not have an interval type.
-- Will use an Integer in seconds instead.
-- Asume negative values for now
SET DELIMITER @
CREATE FUNCTION GetInterval(
 interval_value STRING
) RETURNS INTEGER AS
 RETURN (
  SELECT datediff(SECOND, '1970-01-01 ' || interval_value, '1970-01-01') FROM DUAL
{'fraction_non_alphanumeric': 0.09969879518072289, 'fraction_numerical': 0.01746987951807229, 'mean_word_length': 3.898230088495575, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '7097017', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1071, 'n_words': 379}