diff --git a/Providers/FreeSql.Provider.QuestDb/QuestDbUtils.cs b/Providers/FreeSql.Provider.QuestDb/QuestDbUtils.cs index f898bf64..d957a940 100644 --- a/Providers/FreeSql.Provider.QuestDb/QuestDbUtils.cs +++ b/Providers/FreeSql.Provider.QuestDb/QuestDbUtils.cs @@ -14,10 +14,16 @@ using System.Globalization; using System.Linq; using System.Linq.Expressions; using System.Net; +using System.Net.Http; using System.Numerics; using System.Text; using System.Threading; using FreeSql.QuestDb; +using System.Web; +using System.Threading.Tasks; +using Newtonsoft.Json; +using System.IO; +using CsvHelper; namespace FreeSql.QuestDb { @@ -382,141 +388,4 @@ namespace FreeSql /// M } - - public static class SampleByExtension - { - //是否使用该方法 - internal static AsyncLocal IsExistence = new AsyncLocal() - { - Value = false - }; - - internal static AsyncLocal SamoleByString = new AsyncLocal() - { - Value = string.Empty - }; - - public static void Initialize() - { - IsExistence.Value = false; - SamoleByString.Value = string.Empty; - } - - /// - /// SAMPLE BY用于时间序列数据,将大型数据集汇总为同质时间块的聚合,作为SELECT语句的一部分。对缺少数据的数据集执行查询的用户可以使用FILL关键字指定填充行为 - /// - /// - /// - /// 时长 - /// 单位 - /// - public static ISelect SampleBy(this ISelect select, double time, SampleUnits unit) - { - var _unit = Enum.GetName(typeof(SampleUnits), unit); - IsExistence.Value = true; - var samoleByTemple = $"{Environment.NewLine}SAMPLE BY {{0}}{{1}}{Environment.NewLine}"; - SamoleByString.Value = string.Format(samoleByTemple, time.ToString(), _unit); - return select; - } - } - - public static class LatestOnExtension - { - //是否使用该方法 - internal static AsyncLocal IsExistence = new AsyncLocal() - { - Value = false - }; - - internal static AsyncLocal LatestOnString = new AsyncLocal() - { - Value = string.Empty - }; - - public static void Initialize() - { - IsExistence.Value = false; - LatestOnString.Value = string.Empty; - } - - /// - /// 对于多个时间序列存储在同一个表中的场景,根据时间戳检索给定键或键组合的最新项。 - /// - /// - /// - /// - /// 时间标识 - /// 最新项的列 - /// - public static ISelect LatestOn(this ISelect select, Expression> timestamp, - Expression> partition) - { - Provider(timestamp, partition); - return select; - } - - private static void Provider(Expression> timestamp, - Expression> partition) - { - IsExistence.Value = true; - var latestOnTemple = $"{Environment.NewLine}LATEST ON {{0}} PARTITION BY {{1}} "; - var expressionVisitor = new QuestDbExpressionVisitor(); - expressionVisitor.Visit(timestamp); - var _timestamp = expressionVisitor.Fields(); - expressionVisitor.Visit(partition); - var _partition = expressionVisitor.Fields(); - LatestOnString.Value = string.Format(latestOnTemple, _timestamp, _partition); - } - - /// - /// 对于多个时间序列存储在同一个表中的场景,根据时间戳检索给定键或键组合的最新项。 - /// - /// - /// - /// - /// 时间标识 - /// 最新项的列 - /// - public static ISelect LatestOn(this ISelect select, - Expression> timestamp, - Expression> partition) where T2 : class - { - Provider(timestamp, partition); - return select; - } - - /// - /// 对于多个时间序列存储在同一个表中的场景,根据时间戳检索给定键或键组合的最新项。 - /// - /// - /// - /// - /// 时间标识 - /// 最新项的列 - /// - public static ISelect LatestOn(this ISelect select, - Expression> timestamp, - Expression> partition) where T2 : class where T3 : class - { - Provider(timestamp, partition); - return select; - } - - /// - /// 对于多个时间序列存储在同一个表中的场景,根据时间戳检索给定键或键组合的最新项。 - /// - /// - /// - /// - /// 时间标识 - /// 最新项的列 - /// - public static ISelect LatestOn(this ISelect select, - Expression> timestamp, - Expression> partition) where T2 : class where T3 : class where T4 : class - { - Provider(timestamp, partition); - return select; - } - } } \ No newline at end of file